Paste any JSON and get TypeScript interfaces for it. Nested objects become their own interfaces, arrays become typed arrays, and everything runs in your browser, so API responses and payloads stay private.
.ts or .d.ts file.JSON
{
"user": {
"id": 1,
"name": "Alice",
"tags": ["a", "b"],
"address": { "city": "NYC" }
},
"active": true
}TypeScript
interface Root {
user: User;
active: boolean;
}
interface User {
id: number;
name: string;
tags: string[];
address: Address;
}
interface Address {
city: string;
}| JSON value | TypeScript |
|---|---|
| string | string |
| number (whole or decimal) | number |
| true / false | boolean |
| null | null |
| array of one type | string[] |
| array of mixed types | (string | number)[] |
| empty array | unknown[] |
| object | its own interface, named from the key |
first-name) are quoted automatically.?) are not inferred, because one sample can't show which fields may be missing. Add ? by hand where needed.Describe the same data with the JSON Schema generator, validate it with the schema validator, or generate code for other languages with Java, Go, Python and C#.
The generator analyzes your JSON structure to infer types — strings, numbers, booleans, arrays, and nested objects each become properly typed interface properties. Arrays of mixed types become union types.
The types are inferred from the sample data you provide. For best results, use a JSON sample that includes all possible fields and representative values. Optional fields (?) are not inferred, because a single sample can't show which properties may be missing; add ? by hand where needed. For arrays of objects, the item interface is built from the first object, so put the most complete example first.
The root interface is named based on the JSON structure. You can copy the output and rename interfaces as needed. For nested objects, sub-interfaces are automatically named based on their parent key.