Generate TypeScript interfaces from a JSON sample.
Processed locally in your browser.
How do you generate TypeScript interfaces from JSON?
Each JSON object becomes an interface, nested objects become their own interfaces, arrays infer their element type from the first item, and primitives map to string, number or boolean. For example, {"id":1,"name":"Ada"} produces interface Root with id: number and name: string. Types come from one sample, so optional or mixed fields may need manual tweaks.
Understanding your result
Types are inferred from a single sample, so optional fields, nulls and mixed-type arrays may need manual tweaking. It is a fast starting point you refine by hand.
Formula and method
Each object becomes an interface; nested objects become their own interfaces; arrays infer their element type from the first item; primitives map to string, number or boolean.
Worked example
{"id":1,"name":"Ada"} produces interface Root with id: number and name: string.
How to use this tool
- Paste a JSON sample.
- Name the root interface.
- Copy the generated TypeScript.
Common mistakes to avoid
- Assuming a single sample captures every optional or union field.
- Pasting invalid JSON (use the JSON Formatter to check it first).
About the JSON to TypeScript
The JSON to TypeScript tool generates TypeScript interfaces from a JSON sample, inferring field types and creating separate interfaces for nested objects.
Who should use this tool
TypeScript developers typing API responses and data structures.
Benefits
- Infers string, number, boolean and arrays.
- Generates nested interfaces automatically.
- Names the root interface as you choose.
- Runs locally — JSON never leaves your browser.
Practical use cases
- Typing an API response in TypeScript.
- Bootstrapping models from sample data.
- Documenting a JSON structure.
Explore all Developer Tools tools
Frequently asked questions
Does it handle nested objects?
Yes. Each nested object becomes its own named interface, referenced from the parent.
How are arrays typed?
The element type is inferred from the first item, producing a typed array such as string[] or a nested interface array.