Skip to content

JSON to TypeScript

Generate TypeScript interfaces from JSON

JSON input

Types update as you type

TypeScript

Generated types appear here

How to use

  1. Paste a JSON object or array, for example an API response.
  2. Give the root type a name and choose interface or type.
  3. Copy the generated declarations into a .ts file.

From JSON to type-safe code

Writing TypeScript interfaces for an API response by hand is slow and error prone. This converter infers the shape of your JSON, creates a named interface for every nested object, merges the objects inside arrays to find optional properties and builds union types when a value has more than one type. The output compiles as-is.

Frequently asked questions

When an array contains several objects, their keys are merged. A key that is missing from some of the objects is marked optional with a question mark. You can also mark every property optional.