JSON to TypeScript

Paste JSON and get TypeScript interfaces — instantly, in your browser.

Turn any JSON sample — an API response, a config blob, a fixture — into TypeScript interfaces you can drop straight into your code. Nested objects become named interfaces and arrays get element types. It runs locally, so you can safely paste real production payloads. One sample can’t reveal optionality, so refine ? and | null after generating.



Why generate types from JSON

Hand-writing interfaces for a large API response is tedious and error-prone. Generating them from a real sample gets you 90% of the way in a second: the shape, the nesting, the array element types. You then spend your time on the parts a machine can’t infer — which fields are optional, which strings are really enums, and which numbers are actually IDs that should be typed as strings to avoid precision loss above 2⁵³.

What it infers, and what it can’t

From one sample it infers object shapes, array element types (including unions when elements differ), and primitive types. It can’t know whether a field is sometimes absent, whether a string is one of a fixed set of values, or whether an empty array holds numbers or objects. Treat the output as a strong first draft, not a contract — for a guaranteed contract, generate from a JSON Schema.

Privacy

Inference happens in your browser with no network calls. Your JSON never leaves the tab — paste real responses without worry. The same applies to the formatter and viewer.

Frequently asked questions

What does this tool generate?
It infers a set of TypeScript interfaces from a sample JSON value. Nested objects become their own named interfaces, arrays become typed arrays, and primitives map to string, number, boolean or null.
Is my JSON uploaded?
No. Inference runs entirely in your browser. Nothing is sent to a server — safe for pasting real API responses, including ones with sensitive fields.
How are arrays typed?
The element type is inferred from the array’s contents. If every element has the same shape you get a clean type like Role[]; if the elements differ, you get a union such as (string | number)[].
How accurate is the output?
It is inferred from one sample, so it reflects exactly what you pasted. If a field is sometimes null or missing in real data, mark it optional (field?:) or add | null after generating. For guaranteed-correct types, drive generation from a JSON Schema instead.
Why are some fields not optional when they should be?
A single JSON sample can’t reveal which fields are optional — every key present becomes required. Paste a representative sample, then add ? to keys that may be absent.
Can I use this for API responses?
Yes — that’s the main use case. Paste a real response body and drop the generated interfaces straight into your client code, then refine nullability and optionality by hand.