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:
| JSON | TypeScript |
|---|---|
| string | string |
| number | number |
| boolean | boolean |
| null | null (field marked optional) |
| object | its own named interface |
| array of T | T[] |
| mixed array | union, 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.