JSON to TypeScript Types

Paste JSON, get TypeScript interfaces, type aliases, Zod schemas, or Valibot schemas. Updates as you type.

interface Root {
  id: number;
  user: RootUser;
  active: boolean;
  createdAt: string;
}

interface RootUser {
  name: string;
  email: string;
  tags: string[];
}

01 — Overview

How it works

Convert any JSON sample into a TypeScript type definition or runtime schema. Toggle between interface, type alias, Zod, and Valibot output. Configure root name, optional fields, readonly modifiers, and how to handle nulls. Powered by quicktype.

02 — Use cases

When to use it

  1. 01

    Generate types for a third-party API you only have a sample response from

  2. 02

    Bootstrap a Zod schema from a JSON fixture

  3. 03

    Convert an inherited JSON blob into proper TypeScript before refactoring

  4. 04

    Add runtime validation to a route that previously trusted unknown input

03 — Examples

Real input, real output

{ "id": 1, "name": "Alex", "active": true }

ex 01

interface Root { id: number; name: string; active: boolean; }

Basic interface inferred from a single sample.

{ "items": [{ "id": "a" }, { "id": "b", "label": "B" }] }

ex 02

interface Root { items: Item[]; } interface Item { id: string; label?: string; }

Array items are merged and fields present in only some objects become optional.

{ "id": 1, "name": "Alex" } // Zod output

ex 03

z.object({ id: z.number(), name: z.string() })

Same shape as a Zod schema for runtime validation.

04 — FAQ

Frequently asked

For an array of objects, any field that's missing from at least one object becomes optional. For a single object, every field is required by default. You can toggle the 'mark optional' option to soften this.

05 — More

Tools that pair well