Skip to content
snip tools

JSON to TypeScript interface generator

Generate TypeScript interfaces from JSON. Nested objects, arrays and optional fields are inferred. Runs in your browser.

Runs 100% in your browser
 

How to convert JSON to TypeScript

  1. Paste your JSON. Paste a JSON object or array — a sample API response works well.
  2. Name the root. Optionally rename the root interface.
  3. Copy the interfaces. Copy the generated TypeScript into your project.

About JSON to TypeScript

Typing an API response by hand is tedious and error-prone. Paste a representative sample and get a set of interfaces that match its shape, ready to drop into your codebase and refine. The generator merges every object in an array so optional fields are caught, and names nested interfaces from their keys. Need Go instead? Use the JSON to Go generator.

Frequently asked questions

How does it infer the types?
It walks your JSON and builds TypeScript interfaces: objects become named interfaces, arrays become typed arrays, and arrays of objects are merged into one interface. A key missing from some objects in an array is marked optional with ?.
How are nested objects named?
Each nested object gets its own interface named after its key (singularised for array elements), so users: [...] produces a User interface.
What about mixed or null values?
Mixed types become a union (e.g. string | number); a value that's only ever null becomes null. Empty arrays become any[].
Is my JSON uploaded?
No — inference runs entirely in your browser.