JSON to TypeScript
Generate TypeScript interfaces from a JSON example. Array items are merged, and fields missing from some items are marked optional.
JSON to TypeScript generates TypeScript interfaces from a JSON example. Nested objects get their own named interfaces, items in arrays are merged into one shape, and a field missing from some items is marked optional. Paste a sample API response and copy the types.
How are types inferred?
Merging array items
Every object in an array is looked at, not just the first. Fields that appear in some items but not others become optional (name?: string), and a field with mixed values becomes a union such as string | null.
Naming
Interfaces are named after their key, in PascalCase and made singular for arrays, so "users": [...] gives interface User. Clashing names get a number.
Why use JSON to TypeScript?
- Type an API in seconds. Paste a real response and get a starting point for your client code.
- Catches optional fields. Because all items are merged, rare fields are not missed and are correctly marked optional.
- Private. Responses with real data stay in your browser.
How to use JSON to TypeScript, step by step

- Paste a JSON sample into JSON to TypeScript. The more varied the sample, the more accurate the types.
- Name the root type. Choose whether to add export.
- Copy the interfaces. Paste them into a .ts file and refine names or unions as needed.
Frequently asked questions
Why is a field typed null?
Every value seen for it was null, so its real type cannot be known from the sample. Replace null with the type you expect, such as string | null.
What does unknown[] mean?
The array was empty in every sample, so there was nothing to infer from.
Are date strings typed as Date?
No. JSON has no date type, so they are typed string, which is what the parsed JSON actually contains.
Looking for the long version? The guides cover each of these jobs in depth.