Like ToolFern? Prefer us as your source on Google →

JSON to TypeScript

Paste any JSON and get ready-to-use TypeScript interfaces. Nested objects, arrays and mixed values are worked out for you.

How to use it

  1. Paste JSON into the input box.
  2. Choose the root name and whether to use interface or type.
  3. Press Generate, then copy the result into your project.

How it works

The generator reads your JSON and works out a type for every value. Objects become interfaces named after their key, arrays are merged so that every item contributes to one element type, and keys that appear in only some items become optional. Names are turned into valid PascalCase identifiers.

Frequently asked questions

How are optional fields found?

When the input is an array of objects, a key that is missing from some items is marked optional with a question mark.

What happens with null values?

A null value becomes the type null. If the same key is a string in one item and null in another, the result is string | null.

Does it handle nested objects and arrays?

Yes. Each nested object gets its own named interface, and arrays become typed lists such as Item[].

Are the types guaranteed correct?

The types describe the sample you paste. If other data can differ from the sample, add more examples to the array or edit the result by hand.

Found this useful? Share it