JSON to TypeScript
Paste a JSON payload and instantly get TypeScript interfaces (or type aliases) describing its shape. Optionally mark all properties as optional or readonly. Useful for API mock data, fixtures, or quick type stubs.
How to use JSON to TypeScript
- Paste valid JSON.
- Set the root interface name.
- Pick interface or type alias, and optional flags.
- Copy the generated TypeScript.
What is JSON to TypeScript?
The tool walks the JSON tree, infers types (string / number / boolean / null / array / object), recursively generates a named interface for each object, and assembles them into a clean TypeScript file. Mixed-type arrays become union arrays (e.g., (string | number)[]).
FAQ
- What about discriminated unions?
- Not auto-detected. The tool generates structural types from a single sample. Hand-merge unions if you have multiple samples.