JSON to TypeScript
Paste a JSON response or fixture and generate TypeScript interfaces for nested objects and arrays as a practical starting point.
How it works
Enter your input
Fill in the values, paste your text, or upload the file this tool works with.
See results instantly
Most tools update live as you type; a few use a single button. Either way, the result appears right on this page.
Use your results
Copy, download, or share what the tool produces β you're always in control of the output.
What is JSON to TypeScript?
Infer TypeScript interfaces or type aliases from a JSON sample so API responses and fixtures are easier to type.
How to generate TypeScript from JSON
How inference works
Objects become interfaces, arrays become arrays of inferred item types, primitive roots become type aliases, and nested object names are built from the root name plus the property path.
Arrays and mixed values
When array items have different shapes or primitive types, the output uses a union of the inferred item types. Empty arrays become unknown[] because there is no sample item to inspect.
Review before using
- Rename interfaces if the generated names are too literal.
- Mark fields optional manually when a sample omits some cases.
- Replace null-only fields with a richer union if real data can contain other values.
Typing notes
Generated types describe the sample you pasted. Add optional fields, stricter unions, or shared interfaces when your real API contract is broader than the sample.
Frequently Asked Questions
Does it know which fields are optional?
No. It only sees the provided sample, so every object property in that sample is generated as required.
What happens with invalid property names?
Properties that are not valid TypeScript identifiers are quoted, so keys like user-name remain usable.
Why did I get a type alias instead of an interface?
Primitive JSON roots such as a string, number, boolean, null, or array can be represented directly as a type alias.
Can it merge several response examples?
No. Paste a representative combined sample or adjust the generated types manually after comparing examples.
Related Tools
- PopularAvailableLocal
UUID Generator
Generate standards-compliant UUID v4 and GUID identifiers individually or in bulk.
- PopularAvailableLocal
JSON, YAML & XML Formatter
Format, minify, and validate JSON and XML, and convert between JSON and YAML.
- PopularAvailableLocal
QR Code Generator & Reader
Create QR codes and read QR images locally.
- PopularAvailableLocal
Base64 Encoder/Decoder
Encode and decode text using Base64 locally.
- PopularAvailableLocal
URL Encoder/Decoder
Encode and decode URLs in separate tabs, with batch and recursive options.
- PopularAvailableLocal
Unix Timestamp Converter
Convert Unix timestamps (seconds and milliseconds) to dates and vice versa.
- AvailableLocal
HTML Entity Encoder/Decoder
Encode and decode HTML entities safely.
- AvailableLocal
Regex Tester
Test regular expressions and preview replacements.
- AvailableLocal
JWT Decoder
Decode JWT header and payload locally.
- AvailableLocal
Cron Expression Generator & Validator
Build, validate, and decode 5-field cron expressions with next run times.