JSON to TypeScript Converter
Runs in your browser — your data is never uploaded.
Paste a JSON response and get TypeScript interfaces for it. The types are inferred from the whole sample, not the first record: every element of an array is merged, a key missing from some records becomes optional, and a field that is sometimes null is typed as nullable rather than collapsing to any. Nested objects become their own named interfaces instead of one unreadable inline blob. Everything runs in your browser, so an API response containing real customer data never leaves your machine.
0 characters · runs entirely in your browser
How to use JSON to TypeScript
- 1
Paste a JSON sample — ideally a full API response rather than a single record.
- 2
Set a name for the root interface if you want something other than Root.
- 3
Click “Generate” and copy the interfaces.
Share
Embed this tool on your site
Paste this where you want the tool to appear. It runs entirely in your visitor's browser — no uploads, no account, no tracking.
Please keep the attribution line — it's what keeps these tools free.
Need a different size, a dark theme, or a different tool? Build an embed lets you preview it first.
Frequently asked questions
Why does it read the whole array instead of the first element?+
Because real API samples are ragged. If the first record happens to lack an "error" field, generating from it alone produces a type that compiles and then fails the first time the field appears. Merging every element and marking the difference optional is the only version that survives contact with real data.
How are nulls handled?+
A field seen as null in one record and a number in another becomes number | null. A field only ever seen as null is typed null, since that is genuinely all the sample proves — widen it by hand if you know better.
Why is my array of one item a different shape from an array of two?+
It should not be — the element type is the merge of every element, so one item or fifty gives the same interface. What does change is nesting: a JSON object appearing once gets its own interface named after its key.
Are keys that are not valid identifiers handled?+
Yes. A key like "content-type" is emitted quoted, so the interface is valid TypeScript rather than a syntax error you have to fix by hand.
Is my JSON uploaded?+
No. Inference and code generation both run entirely in your browser. That matters here more than most: the JSON developers paste into a type generator is usually a real response with real user data in it.