JSON to TypeScript
Paste sample JSON and get the matching TypeScript interfaces — no more typing out every field by hand when working with API data.
How to generate TypeScript interfaces from JSON
- Paste your sample JSON on the left and the TypeScript declarations appear on the right.
- Change the name of the outermost type in the "Root type name" box if you like, for example ApiResponse.
- Use the copy button and paste it into your code.
Frequently asked questions
Entirely from the data you paste: text is string, numbers are number, true/false is boolean, and objects nested inside are split out into their own interfaces.
The field isn't always there. When an array holds several objects and only some of them have that field, the tool marks it as optional.
The tool joins the types with |, for example string | number. If the value is sometimes null, the type gets | null as well.
An empty array has no items for the tool to learn the type from. Fix it by hand, or paste a sample that has data in the array.
After the field, with a capital first letter (user_profile becomes UserProfile). Array items get Item added to the end, and a name that's already taken gets a number: 2, 3…
No, they're only as accurate as the sample you paste. Use a complete sample — ideally several items in each array, including fields that are sometimes missing — so the types cover real-world cases.
No. The JSON is processed right on your device.
It's completely free, no account needed.
Related tools
JSON to JSON SchemaGenerate a JSON Schema from a JSON sampleJSON to ZodGenerate a Zod schema from a JSON sampleJSON Schema validatorCheck whether JSON data matches a JSON SchemaJSON to Go structGenerate Go structs from a JSON sampleJSON to Python dataclassGenerate dataclasses or Pydantic models from JSONJSON to Java classGenerate Java classes or records from JSONJSON to Kotlin data classGenerate Kotlin data classes from a JSON sampleJSON Escape / UnescapeTurn text into a valid JSON string and backJSON FormatterFormat, minify and validate JSON