Search tools

JSON to TypeScript Interface

Paste a sample API response and get TypeScript types for it in one step.

JSON to TypeScript Interface tool

Options

Processing runs in your browser.

Typing API responses by hand is slow and error-prone, especially for large nested payloads. Generating a first draft from a real sample gets you 90% of the way: you get the structure right immediately and only need to adjust names and edge cases.

Uses

  • Front-end apps consuming REST APIs without published types.
  • Integrations with third-party webhooks.
  • Prototyping: get type safety while an API is still changing.
  • Documentation: describe a payload’s shape for teammates.

How to use the JSON to TypeScript Interface

  1. Paste sample JSON — for example, a real API response.
  2. Set the root type name, such as User or OrderResponse.
  3. Choose interface or type alias.
  4. Copy the generated types into your project, then refine names and add documentation.

Features

  • Nested objects become separate named interfaces.
  • Arrays of objects are merged: fields missing from some items become optional (field?).
  • Mixed arrays become union types, such as (string | number)[].
  • Keys that aren’t valid identifiers are quoted.

Frequently asked questions

How are null values typed?

A field that is null in the sample becomes null. If it can also hold another type, change it to something like string | null by hand — one sample can’t show every case.

Why are some fields optional?

When an array contains several objects and a field appears in only some of them, it’s marked optional with ?. Paste a sample that includes several items for the most accurate types.

Can it detect dates?

No. JSON has no date type, so dates arrive as strings and are typed as string. Convert them in your code where needed.

Written by