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 the JSON to TypeScript Types 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 the JSON to TypeScript Types
- 01
Generate types for a third-party API you only have a sample response from
- 02
Bootstrap a Zod schema from a JSON fixture
- 03
Convert an inherited JSON blob into proper TypeScript before refactoring
- 04
Add runtime validation to a route that previously trusted unknown input
03 — Examples
JSON to TypeScript Types examples
{ "id": 1, "name": "Alex", "active": true }
ex 01interface Root { id: number; name: string; active: boolean; }
Basic interface inferred from a single sample.
{ "items": [{ "id": "a" }, { "id": "b", "label": "B" }] }
ex 02interface 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 03z.object({ id: z.number(), name: z.string() })
Same shape as a Zod schema for runtime validation.
04 — FAQ
JSON → Types — frequently asked questions
How does the tool decide whether a field is optional?
What's the difference between an interface and a type alias?
When should I use Zod or Valibot instead of TypeScript types?
Why is a number sometimes typed as 'number' and sometimes as a literal?
How do nulls become 'unknown'?
Does it support deeply nested objects?
05 — Reference
Specs and further reading
The primary sources this tool follows. Where behaviour is defined by a specification, we link the specification rather than a summary of it.
- RFC 8259: The JSON Data Interchange Format
IETF — The normative definition of JSON, including its value types and encoding rules.
- TypeScript everyday types
Microsoft — Reference for the interface and type-alias forms this tool emits.
- Zod
Zod — Documentation for the runtime schema output option, including inference to static types.
- quicktype
quicktype — The type-inference engine used to derive types from a JSON sample.
07 — More
Tools that pair with JSON → Types
Regex Generator
Describe what you want to match in plain English. Get a regex pattern with a live test panel and a token-by-token breakdown.
UUID Generator
Generate UUIDs (v1, v4, v7, v8) in bulk, with format options and a validator. Cryptographically random by default.
Lorem Ipsum Generator
Generate placeholder text in seconds. Classic Latin or modern variants — corporate, hipster, bacon. By paragraphs, sentences, or words.