jsonparse.io
100% client-side

JSON to TypeScript Interface Generator

JSON → TypeScript

JSON input

TypeScript output

What does the JSON to TypeScript generator do?

It reads a sample of JSON and generates TypeScript types that describe its shape. Strings, numbers, booleans and null values get their matching types, nested objects become their own named interfaces, and arrays are typed from all of their items. The top-level type is exported as Root, ready to paste straight into your project.

This saves time when you work with a REST API or a JSON config file and want type checking and editor autocompletion for the data you receive.

How do you generate TypeScript types from JSON?

  1. Paste a sample JSON object, such as an API response, into the input editor.
  2. Review the generated interface in the output panel.
  3. Copy or download the result, then rename Root to match your data.

Frequently asked questions

Are optional properties detected?

Yes, in arrays of objects: a key that is missing from some items is marked optional, for example email?: string. In a single object every key is required, because one sample can't show which fields are sometimes left out.

How are arrays typed?

From all of their items. An array of numbers becomes number[], mixed items become a union such as (string | number)[], and an empty array becomes unknown[] because there is no item to infer a type from.

What type does a null value get?

It is typed as null. If the field can also hold another type, change it to a union such as string | null.

Is my data uploaded?

No. The types are generated in your browser and your JSON stays on your device.