JSON to TypeScript
Generate TypeScript interfaces or type aliases from a JSON sample. Nested objects become named types, arrays of objects merge their shapes (keys missing from some elements become optional), and nulls become unions with null. One sample cannot describe every real payload, and the generated header says so.
JSON
TypeScript
Result will appear hereReady. Press Generate or Ctrl+Enter.
How to use the JSON to TypeScript
- Paste a JSON sample.
- Choose interface or type alias style and a root name.
- Press Generate and copy the types.
Example
The author object becomes its own named interface.
{
"name": "json-utils",
"version": "1.0.0",
"private": false,
"tags": ["json", "tools"],
"author": { "name": "Ada", "active": true },
"score": 9.5,
"notes": null
}Frequently asked questions
How are arrays of objects handled?
All elements merge into one shape. A key present in only some elements becomes optional, and keys with differing types become unions.
Should I trust the output blindly?
No. Types are inferred from one sample. Optional fields in real payloads look required here if the sample always has them. Review before shipping.