JSON to TypeScript
100% private — runs on your device, never uploaded. Works offline once loaded.
Paste any JSON and get clean TypeScript interfaces, with nested objects promoted to their own interfaces and arrays typed as T[]. Everything runs locally in your browser.
What the generator produces
This tool reads a JSON sample and emits one or more TypeScript interface declarations that describe its shape. Primitive values map to string, number, and boolean; a JSON null becomes the literal type null. Every nested object is lifted into its own named interface — a profile field on a User interface produces a separate UserProfile interface and references it — which keeps deeply nested data flat and easy to read instead of collapsing into one giant inline type.
How arrays and mixed types are inferred
Arrays are typed as T[], where T is inferred from the elements. When an array mixes types — say numbers and strings — the tool emits a union like (number | string)[]. Arrays of objects are the interesting case: rather than generating a different interface per element, the tool merges every object in the array into a single interface. Any key that appears in some but not all elements is marked optional with a ?, which mirrors how real API responses often omit fields.
When to reach for it
Hand-writing types for a third-party API response is tedious and error-prone. Paste a real sample payload here and you get a first draft of the types in seconds, ready to paste into a .ts file and refine. It is also handy for typing fixtures in tests, config files, and GraphQL or REST responses you are integrating against.
- Typing an untyped fetch() response before wiring it into your app
- Bootstrapping types from a Postman or curl response sample
- Generating DTOs for a form payload or webhook body
- Documenting the shape of a legacy JSON config
Limits worth knowing
Inference is only as good as the sample you paste — a field that is always null in your sample is typed as null, because there is nothing else to infer from. For unions across optional or absent values you may want to widen a type by hand afterwards. The tool also treats every JSON number as number; it does not distinguish integers from floats, since TypeScript itself does not.
Frequently asked questions
Can I paste a top-level JSON array?
Yes. A root array produces a type alias like export type Root = Item[]; along with an interface for the element shape when the elements are objects.
Why did a field come out as `any`?
That happens when the tool has no value to infer from — for example an empty array with no elements. Widen or narrow it manually once you know the real shape.
How are keys that aren't valid identifiers handled?
A key with spaces, dashes, or other symbols is emitted as a quoted property, like "first-name": string;, which is valid TypeScript.
Does it generate types or interfaces?
It generates interfaces for objects and a type alias for a top-level array or primitive, following common TypeScript conventions.
Can I rename the root interface?
Yes — use the root name field. Nested interface names are derived from it and the key path so they stay unique and descriptive.
Is very large JSON supported?
There is no artificial size limit. Because everything runs locally, only your browser's memory bounds how large a sample you can convert.
Advertisement