JSON to TypeScript

Generate TypeScript interfaces from a JSON sample, with nested types.

INPUT
OUTPUT
TypeScript interfaces will appear here.

About the JSON to TypeScript

JSON to TypeScript turns a sample JSON payload into ready to use TypeScript interfaces in a single step. Paste a response from an API, a config file, or any object literal, give the root interface a name, and the tool reads the shape of your data and writes matching type declarations you can drop straight into an editor.

The generator walks the whole structure recursively. Strings, numbers, and booleans map to their primitive types, null stays as null, and arrays become a typed list inferred from their first element. When a value is itself an object, it is promoted into its own named interface using a PascalCase version of the key, so deeply nested data stays readable instead of collapsing into one giant inline type.

Arrays of objects get special handling. Rather than typing only the first item, the tool merges the keys across every element in the array. Any key that is missing from one or more items is marked optional with a question mark, which mirrors how real API collections often vary from record to record. The result is a single interface that safely describes the entire list.

Everything happens in your browser. The JSON you paste is parsed and converted locally with plain JavaScript, and nothing is uploaded, logged, or sent to any server. You can use it on private or sensitive payloads without the data ever leaving your machine.

Your ad could be here

Reach developers and designers who use these tools every day. Privacy-first, no trackers.

Frequently asked questions

How do I generate a TypeScript interface from JSON?

Paste your JSON into the input box and the interfaces appear instantly in the output panel. Set the root interface name if you want something other than Root, then copy the generated code into your project.

Does it create separate interfaces for nested objects?

Yes. Each nested object becomes its own named interface, derived from the key it sits under and converted to PascalCase. The parent interface references that named type instead of inlining it, which keeps complex structures easy to read.

How are arrays of objects handled?

The tool merges the keys from every object in the array into one interface. Keys present in all elements stay required, while keys missing from any element are marked optional with a question mark so the type matches the whole collection.

What happens with empty arrays or null values?

An empty array cannot be inspected for its element type, so it is typed as unknown[]. A null value is typed as null. You can refine these by hand afterward if you know the intended shape.

Is my JSON uploaded or stored anywhere?

No. The conversion runs entirely in your browser using local JavaScript. Your JSON is never sent to a server, saved, or shared, so it is safe to use with private data.