JSON to TypeScript Converter
Paste a JSON sample and get TypeScript interfaces, with nested objects hoisted into their own named types.
This free online JSON to TypeScript converter infers a type for every value in your sample — objects become interfaces, arrays infer their element type, and fields that aren't present on every array element are marked optional. No signup required, runs entirely in your browser.
Root interface name
Output style
Arrays of objects are merged into one representative interface. Fields missing from some elements become optional (?); fields with different types across elements become a union.
How this JSON to TypeScript converter works
Paste a JSON sample into the input box above. The tool parses it and walks every value, building a type for each one: strings, numbers, booleans, and null map directly to their TypeScript equivalents, arrays infer the type of their elements, and objects become interfaces. Every nested object is hoisted into its own named interface — named after the property key that contains it, PascalCased — rather than being inlined, so the output stays readable and each shape is reusable.
How arrays and mixed shapes are handled
When an array contains objects, the tool merges all of the elements' shapes into a single representative interface. A field is only required in the output if it's present on every element; if it's missing from some, it's marked optional with ?. If the same field holds different primitive types across elements — a number in one, a string in another — the tool generates a union type such as string | number instead of guessing. Two different object shapes that would otherwise get the same interface name (for example two unrelated address fields) are kept distinct by appending a numeric suffix, like Address2.
Limitations
This tool infers types from the sample you paste in — it has no access to your actual schema or the rest of your dataset. If a field can hold a type or shape that doesn't appear anywhere in your sample, the generated interface won't account for it. Treat the output as a strong starting point and review it against your real data before relying on it, especially for fields that are sparsely populated in the sample.