JSON to TypeScript

Skip to editor
Explorer
Open Files

No files open

0 files open

jsoneditor.io v2

No file open

Create a new file or open an existing one from the sidebar

JSONUTF-8
Spaces: 2

How do I generate TypeScript types from JSON?

To generate TypeScript types from JSON, paste a sample above, open Convert and press Generate Types. The interfaces open in a new tab, ready to copy into your project.

Every nested object gets its own exported interface named after its key, and arrays of objects are merged, so a key that only some items have becomes optional. Mixed values turn into unions like string | null, keys that aren't valid identifiers are quoted, and identical shapes share one interface.

  1. Paste a sample JSON response into the editor.
  2. Open Convert and press Generate Types.
  3. Copy the interfaces from the new tab.

Example

JSON
{
  "page": 1,
  "users": [
    {
      "id": 1,
      "name": "Ada",
      "email": "ada@example.com",
      "last-login": "2026-10-01T09:30:00Z",
      "team": {
        "id": 7,
        "name": "Platform"
      }
    },
    {
      "id": 2,
      "name": "Linus",
      "email": null,
      "team": {
        "id": 7,
        "name": "Platform"
      }
    }
  ]
}
TypeScript
export interface Root {
  page: number;
  users: User[];
}

export interface User {
  id: number;
  name: string;
  email: string | null;
  "last-login"?: string;
  team: Team;
}

export interface Team {
  id: number;
  name: string;
}

Questions people ask

How accurate are the generated types?

As accurate as your sample. The generator only knows what it can see, so if a field can be null but never is in your sample, the type won't include null. A response with a few varied items gives the best result.

How are the interfaces named?

After their keys. Array items use the singular, so users gives you a User interface, and when there's no obvious singular, Item is added to the name.

Can it generate Zod schemas or classes?

Not yet, it generates TypeScript interfaces and type aliases.

Is my data uploaded anywhere?

No, this runs entirely in your browser, so nothing you paste is sent to a server. The only feature that sends data anywhere is the optional AI assistant, and only when you actually ask it something.