JSON to TypeScript Interfaces
Paste an API response, get typed interfaces.
Paste a JSON sample, typically an API response, and get TypeScript interfaces that describe it. Each nested object becomes its own named interface, arrays are typed from their elements, and the root type is exported as Root.
When an array contains objects with different keys, the shapes are merged: a field that is missing from some elements is marked optional, and a field that holds more than one type becomes a union.
How to use it
- Paste a representative JSON sample into the left editor.
- Review the generated interfaces on the right.
- Copy them into your project and rename Root to suit your model.
Questions
How are optional fields detected?
Only by comparing the objects inside an array. A key missing from at least one element is marked optional. A single sample object cannot reveal which fields are optional.
How is null typed?
A null value is typed as null and combined into a union when other samples of the same field have a value, for example string | null.
Does it work from YAML or XML?
Yes. Any supported input format is parsed first, so you can generate types from YAML, XML, CSV, JSONL or TOON as well.
All tools
- JSON Formatter
- JSON Validator
- JSON Minifier
- JSON Repair
- JSON Diff
- JSON Schema Validator
- JSON to YAML
- YAML to JSON
- JSON to CSV
- CSV to JSON
- JSON to XML
- XML to JSON
- YAML Formatter
- XML Formatter
- JSONL Validator
- JSON to TOON
- LLM Token Counter
- LLM Token Optimizer
- JSON to TypeScript
- JSON Schema Generator
- LLM Tool Schema Generator