About this tool
A JSON-to-TypeScript converter reads a JSON document and infers a static type for it: scalars map to string, number, and boolean; arrays become T[]; and nested objects are extracted into their own named interfaces rather than being inlined. This tool walks the whole value tree, merges the keys of every object in an array (marking keys that are absent from some elements as optional), de-duplicates objects with identical shapes so they reuse one interface, and quotes any property name that isn't a valid identifier. null values union with their sibling type when one is seen, empty arrays become unknown[], and empty objects become Record<string, unknown>.
Use it to turn an API response into typed models without hand-writing them, to scaffold interfaces from a fixture or config file, or to sanity-check what shape a payload actually has before wiring it into your code. Rename the root type, toggle between interface and type output to match your codebase conventions, and the result regenerates live as you paste or edit — then copy it straight into a .d.ts or model file.
Generated types reflect only the sample you paste — fields that happen to be absent or null in your example may still appear in real data, so review optionals and null unions before trusting them.
Frequently asked questions
Does it generate TypeScript interfaces or type aliases?
Both. The default is interface, which is best for object models you may want to extend or merge; switch to the type toggle to emit type aliases instead, which can express unions and tuples that interfaces can't.
How does it handle an array of objects with different keys?
It merges the keys across every element into a single interface. Any key that is missing from at least one element is marked optional with a ?, so the generated type safely describes all elements in the array.
Why do two nested objects share the same interface name?
Objects with an identical set of fields and field types are de-duplicated into one named interface and reused, which keeps the output compact and avoids near-identical duplicate definitions.