Runs 100% in your browser — nothing uploaded

JSON to TypeScript Interface Generator

Paste a JSON object or API response and get clean TypeScript interfaces — nested types, array elements, primitive unions and optional properties all inferred automatically, live in your browser.

JSON input
TypeScript
Ready — types are inferred locally, nothing uploaded.

How to convert JSON to TypeScript

Paste a JSON value into the input box and the matching TypeScript interfaces appear instantly on the right. Set the root name to whatever you want the top-level interface called, and toggle export to prefix each interface for use across modules or readonly to mark every property immutable. The output is ready to drop straight into a .ts file. It is built for the common job of turning a real API response or a fixture payload into typed code, so your editor can autocomplete fields and catch typos at compile time instead of at runtime.

How types are inferred

The generator walks your JSON and maps each value to a TypeScript type. Strings, numbers and booleans become string, number and boolean; null becomes the null type. Every object becomes its own named interface, and the property that held it references that interface by name — so structure is preserved rather than flattened into one giant inline type. Interface names are derived from the property key; for an array of objects the tool uses the singular of the key, so an orders array yields an Order interface. The top-level interface is emitted first, with its dependencies below it, matching how you would write the file by hand.

Optional keys and union types

Real data is rarely perfectly uniform, and the generator handles that. When an array holds several objects, their shapes are merged: a property that appears in every element is required, while one that appears in only some is marked optional with a ?. If the same property has different types across elements — a number in one, a string in another — the result is a union like number | string. Mixed primitive arrays become a union element type such as (string | number)[]. This means a single representative sample usually produces a type that already accounts for the variation in your data.

Limits and edge cases

Type inference from data is inherently a best guess, so a few cases need a human eye. An empty array becomes any[] because there is nothing to infer an element type from; supply a populated sample for a precise type. A null value is typed literally as null — if the field is really "string or null" you will want to widen it. The tool does not invent enums, branded types or date types: an ISO timestamp is a string, because that is what JSON actually carries. Treat the output as an accurate first draft that you refine, not an oracle.

Why generate types locally

Generating types is a deterministic transform of your data, which makes a real tool more trustworthy than asking an AI assistant to "write the types" — a model can hallucinate fields that are not present, drop ones that are, or quietly guess the wrong shape, and you would not notice until the type lies to you. This generator only reflects what is actually in the JSON. It also runs entirely in your browser, so a production API response — which may contain real user data — is parsed locally and never uploaded, in line with the gitime.dev default.

Frequently asked questions

How are nested objects handled?
Each becomes its own named interface; arrays use the singular of the key for the element interface name.
How are optional properties detected?
By merging object shapes in an array — keys missing from some elements become optional, differing types become unions.
What about empty arrays or null?
Empty arrays become any[] and null becomes the null type; widen these by hand once you know the intent.
Is my JSON uploaded?
No. Parsing and inference run locally in your browser.

Related tools