JSON to TypeScript
Turn a JSON sample into TS interfaces.
What would you like to do next?
Generate TypeScript types from a JSON sample
Drop in an example JSON response and this tool infers a matching set of TypeScript interfaces, so you can type an API or config without writing the shapes by hand. It walks the whole structure: nested objects become their own named interfaces, arrays become typed lists, mixed arrays become a union of their element types, and a value that is null is marked optional so it will not fight your strict settings. The root type takes whatever name you choose, defaulting to Root, and the interfaces are emitted ready to paste into a .ts file. Inferring types from a real payload is far quicker and less error-prone than typing them out, and it keeps your front-end definitions honest about what the server actually sends. Everything is parsed in your browser, so unpublished payloads never leave your machine.
What it infers
Primitive values map to string, number or boolean; objects become interfaces named after their key; arrays become element[]; and null values are made optional. Tidy the result for edge cases the sample did not cover.
Frequently asked questions
How are nested objects handled?
Each nested object becomes its own interface, named after the key it appears under, and the parent references it. This keeps the output readable and reusable.
What happens with arrays of mixed types?
The element types are combined into a union, such as (string | number)[], so the generated type covers every value seen in the sample.
Why are some fields marked optional?
A property whose sample value is null is marked optional, since the type cannot be inferred. Adjust it once you know the real shape from your API.