JSON to TypeScript

Paste an API response or any JSON and get TypeScript types for it. Nested objects become their own named interfaces, arrays of objects are merged into one type with optional fields where items differ, and identical shapes share a name. Choose interface or type, export, readonly and the root name, then copy or download a .ts file.

Write as
JSON sample
TypeScript

Types come from this one sample. A field that is sometimes missing or null in real data needs a second sample (paste an array of both) or a manual ?.

Processing runs in your browser. What you type never leaves this device.

Features

  • interface or type alias output

  • Named types for nested objects

  • Array items merged; missing keys marked optional

  • Unions for mixed values (number | string)

  • Identical shapes reuse one type

  • Quoted names for keys like "first-name"

When to generate types from JSON

Typing an API response

Paste a real response from a payment gateway, courier or CRM API and get types to start from.

Migrating JavaScript to TypeScript

Generate types for fixtures and config objects instead of writing them by hand.

Documentation

Show the shape of a webhook payload in a readable form for your team.

Making the types accurate

One sample is a guess

Types come from the values you paste. If a field can be null or missing in real data but is filled in your sample, the type will not show it. Paste an array with several real items so the generator can see the differences.

Dates, IDs and enums

  • Dates in JSON are strings, so they are typed string.
  • A status field shows as string even if only a few values are allowed; narrow it to a union by hand.
  • Empty arrays become unknown[] until a sample has items.

Related tools

Need a schema for validation instead? Use the JSON Schema generator.

JSON to TypeScript - FAQ