← back to flaviocopes.com

JSON to TypeScript

← All tools

Paste JSON and generate TypeScript interfaces — nested objects become named types, mixed arrays become unions, and keys missing in some array items turn optional.

Your JSON never leaves the browser — no upload, no server.

~~~

Input

~~~

Options

Declaration style

~~~

Output

~~~

About this tool

Turning API responses into TypeScript types is tedious when objects nest deeply or array items don't share the same keys. This generator walks the JSON structure and emits interfaces (or type aliases) you can drop into a .ts file.

Optional properties are inferred when you paste an array of objects and some items omit a key — a common pattern in real API payloads. Mixed array element types become unions. Edit the root name if you wantUserResponse instead ofRoot.

~~~

Read more