JSON to TypeScript Converter - Generate Interfaces from JSON
JSON to TypeScript
Turn a sample API response into ready-to-use TypeScript types
Types from a Sample
Paste any JSON and get interfaces or type aliases straight away, updating as you edit.
Smart Array Merging
Objects in an array are combined into one type, and any property that is missing from some of them becomes optional.
Your Style
Choose interface or type, export, readonly, semicolons, indentation and unknown or any.
Full Privacy
Your JSON is processed in your browser and never uploaded.
How the Types Are Inferred
The tool reads your sample and works out a type for every value: strings, numbers, booleans and null map directly, arrays become T[], and each object becomes a named interface, with names taken from the property they sit under (an "orders" array gives an Order interface). When an array holds several objects, their properties are merged and any that appear in only some of them are marked optional with a question mark.
A sample can only show what it contains, so review the result. A field that is always a number in your sample might sometimes be a string in the real API, an empty array gives unknown[], and a value that is null in the sample gives just null. Widen those types by hand where you know better, and treat the output as a starting point rather than a contract.
Key Takeaways
- Shared shapes: Identical nested objects reuse one interface instead of repeating it.
- Safe names: Keys that are not valid identifiers, like "first-name", are quoted.
- Related tools: See also the JSON Formatter, the JSON Validator and the JSON Diff Checker.