JSON to TypeScript
Paste a JSON response and get clean TypeScript interfaces, with nested types, arrays and optional fields worked out for you.
How types are inferred
- Each object becomes an
interface, named after its key in PascalCase ("billing_address"→BillingAddress). - Arrays of objects are merged into one interface. A key missing from some items becomes optional (
key?: string). - Mixed values become unions, like
string | number.nullbecomes| null. - Empty arrays become
unknown[], because their item type can't be known from the sample.
Tips
Paste a response with as many variations as possible (for example several array items) so optional fields and unions are detected. Choose type instead of interface if your code style prefers type aliases.
Everything runs in your browser. Nothing you paste is uploaded, logged or stored on a server.
Questions
Interface or type alias?
Both work for object shapes. Interfaces can be extended and merged; type aliases can express unions. Pick whichever your codebase uses.
Does it handle deeply nested JSON?
Yes. Every nested object gets its own named interface.