Skip to content

JSON to TypeScript

Paste an API response or any JSON sample: nested objects become named interfaces and arrays get proper types. Fields missing from some items are marked optional (?). Your JSON never leaves your browser.

This tool runs entirely in your browser; what you enter is never sent to our servers.

How to use it

  1. Paste a JSON sample on the left.
  2. Choose the root name and interface or type style.
  3. Copy the TypeScript and add it to your project.

How JSON becomes types

The tool looks at the type of every value: text becomes string, numbers number, true/false boolean and null null. Each nested object becomes its own interface named after its key (address → Address), and arrays of objects get a singular name (users → User). All objects in an array are merged into one type: keys missing from some items become optional (?), and values of different types become a union (string | number). Objects with the same shape share one interface. An empty array becomes unknown[], because the sample does not show what goes in it. The types only reflect the sample you give: fields or values that never appear in it cannot be in the type. For a better result, use a response with several different items and review the output.

Frequently asked questions

Help us improve this tool