JSON to TypeScript Interface

Generate TypeScript interfaces from a JSON sample.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

Generate TypeScript interfaces from JSON

Writing TypeScript interfaces to match an API response by hand is tedious and easy to get wrong. Paste a representative JSON sample and this tool infers the matching TypeScript interfaces for you, ready to drop into your project.

How it works

The generator walks the sample and types each value, naming a fresh interface for every nested object after its PascalCased key:

JSONTypeScript
stringstring
numbernumber
booleanboolean
nullnull (field marked optional)
objectits own named interface
array of TT[]
mixed arrayunion, e.g. (number | string)[]

Example

This JSON:

{ "id": 7, "user": { "name": "Sam" }, "tags": ["a", "b"] }

generates:

interface Root {
  id: number;
  user: User;
  tags: string[];
}

interface User {
  name: string;
}

Because the types are inferred from one sample, they reflect exactly what’s in that sample — fields that are optional or absent won’t appear, so treat the output as a strong starting point. All inference happens in your browser — your data is never uploaded or stored.

Ad placeholder (rectangle)