In short: JSON to TypeScript generates interface declarations from a sample JSON value, inferring string, number, boolean, array, optional and nested object types.
About JSON to TypeScript
Writing interfaces by hand for a large API response is slow and error-prone. This generator reads a sample JSON value and produces TypeScript declarations: primitives become string, number or boolean, nested objects become their own named interfaces, and arrays become typed arrays.
When an array contains objects with different keys, keys missing from some items are marked optional with ?, and mixed value types become unions such as string | number. null values are typed as null, so review them — a sample with null usually means “sometimes a value, sometimes not”.
How to use JSON to TypeScript
- Paste a representative JSON sample (an array of several items gives better optional-field detection).
- Set the root type name and choose
interfaceortype. - Press Generate types and copy the declarations into your project.
Examples
{"user":{"id":1,"name":"Ada"}} produces interface Root { user: User } and interface User { id: number; name: string }.
[{"a":1,"b":"x"},{"a":2}] produces an item type where b?: string is optional.
Frequently asked questions
Are the types guaranteed to match my API?
They match the sample you paste. If a field can be missing or null in other responses, the sample may not show it, so check the result against your API documentation.
How are keys that are not valid identifiers handled?
Keys such as first-name or 2fa are quoted, for example "first-name": string.
What happens with empty arrays?
They are typed as unknown[] because there is nothing to infer from.
Is my JSON uploaded?
No. The generator runs in your browser. You can check this yourself: open your browser’s developer tools, switch to the Network tab and use the tool — no request carries your input.
Updated November 2026 · Free, no signup · How we build and test tools