JSON to TypeScript Interface Generator

Generate TypeScript interfaces from a JSON sample.

Runs in your browser Developer Tools Free · No account

Input

Processed locally

This tool runs entirely in your browser. The data you paste or load is never uploaded.

Result

Enter your input, then run the tool.

About this tool

Infers TypeScript interfaces from a JSON example, naming nested objects after their keys, merging the shapes of array items and marking keys that are missing from some items as optional. Paste an API response and copy ready-to-use types.

How to use it

  1. Paste a JSON object or array, such as an API response.
  2. Choose the root interface name and the declaration style.
  3. Press Generate and copy the TypeScript.

Frequently asked questions

How are arrays of objects handled?
The keys of every item are merged into one interface. A key missing from some items becomes optional (key?: type).
What type does null get?
A key that is null in the sample becomes “type | null”, or “unknown | null” when no other value tells the real type.

Keep going

More in this category