JSON to TS

Paste a JSON sample and get TypeScript interfaces that describe it, nested types included.

Runs in your browser — nothing you type here is sent anywhere.
JSON sample
Root name
3
types
TypeScript
export interface User {
  id: number;
  name: string;
  active: boolean;
  profile: Profile;
  tags: string[];
  posts: Post[];
}

export interface Profile {
  url: string;
  avatar: null;
}

export interface Post {
  slug: string;
  views: number;
  pinned?: boolean;
}
rootUser
declaredUser, Profile, Post
lines19

Every element of an array is inspected, not just the first: a key that is missing from some elements comes out optional, and mixed values come out as a union. Nested objects get their own interface named after their key, numbered on collision. Empty arrays become unknown[].

Typing an API response by hand is tedious and error-prone, particularly when it is deeply nested or has arrays of objects several levels down.

The sample is analysed and interfaces are generated for every level, with nested objects extracted into their own named types and arrays typed from their contents. Values that are null or absent are handled as optional rather than typed away.

What people open it for

In the terminal

tools jsonts

Every utility is also a command in the desktop's shell.

More text tools

Open the full desktop, with all 47 utilities