Skip to main content
JSON → TS

JSON to TypeScript

Paste a JSON sample, such as an API response, and get TypeScript interfaces or type aliases with nested types, optional fields and nulls worked out.

Output
Input241 characters · 13 lines
Result235 characters · 16 lines
export interface Root {
  id: number;
  name: string;
  email: string;
  isActive: boolean;
  address: Address;
  tags: string[];
  scores: number[];
}

export interface Address {
  street: string;
  city: string;
  zipCode: string;
}
Learn more

JSON to TypeScript: what you get

Types from a real payload

Writing types for an API response by hand is slow and drifts from reality. Paste a real response and every nested object becomes a named interface, arrays get the type of their items, and you choose the root name and interfaces or type aliases.

How the shapes are inferred

When an array holds several objects, their fields are merged: a field missing from some items is marked optional (?), a field that is null somewhere becomes a union such as string | null. The more varied the sample, the more accurate the types; review fields that were always null, typed as null only.

How it works

How to convert JSON to TypeScript

  1. Paste your JSON

    Paste JSON data into the left panel. Sample data is provided to get you started.

  2. Choose output format

    Select 'interface' or 'type' alias mode. Optionally set a custom root name.

  3. Convert and copy

    The TypeScript types update as you type (export can be turned off). Copy them or download a .ts file.

Practical guides

Tips & guides

Why type your JSON?

TypeScript interfaces catch bugs at compile time by ensuring your code matches the shape of your data. Converting API responses to types means fewer runtime errors.

Instead of manually writing types for complex nested API payloads, paste the response and get accurate types in seconds.

Pro tip

Private

Your JSON data stays in your browser. Nothing is uploaded, stored, or tracked.

Internal API responses stay internal: the types are generated in your browser.

Privacy
Frequently asked questions

Frequently asked questions

Everything you need to know about JSON to TypeScript conversion