JSON to TypeScript Interfaces

Generate TypeScript interfaces from a sample JSON payload, with nested types, optional properties inferred from arrays, and safe property names.

Runs on your device

Result

Results appear here after you select “Generate”.

What it does

Paste a real API response and get typed interfaces to start from. Arrays of objects are merged so keys missing from some items become optional.

How to use it

  1. Paste sample JSON.
  2. Name the root type.
  3. Generate and copy the interfaces into your project.

Example

The example fills in realistic values and runs the tool. Select Try an example above to see it.

When it helps

  • Typing a third party API quickly.
  • Documenting payload shapes.
  • Starting a frontend model layer.

Questions

Are the types exact?

They describe the sample you pasted. A field that is a number in the sample but sometimes a string in production will need adjusting by hand.

How are null values typed?

As null. Widen them to the real type (for example string | null) once you know it.

More developer tools

See all 25

People also use

Browse all 200 tools