JSON to TypeScript
Generate TypeScript interfaces from a JSON sample with optional and union types.
Input
Result
How to use
Generating TypeScript interfaces
Paste a JSON sample and press Convert to obtain interfaces. Union types are produced for mixed arrays.
- Paste a JSON sample.
- Press Convert.
- Copy the interfaces into your project.
Frequently asked questions
Are fields marked optional?
Fields missing from the sample are not inferred, so optionality is only added when a value is null.
How are arrays typed?
Homogeneous arrays use a single type, mixed arrays produce a union type and empty arrays produce unknown[].
Related tools
JSON to C# Class
Generate strongly typed C# classes from a JSON sample in a single click.
JSON Formatter
Beautify and validate JSON with configurable indentation, error highlighting and one click copy.
JSON Parser
Parse JSON and inspect the resulting structure, types and value counts.
JSON Validator
Check whether your JSON is valid and see a clear explanation of any syntax problem.
JSON Minifier
Remove every unnecessary space and newline to produce the smallest possible JSON payload.
JSON Viewer
Read JSON in a clean formatted view and explore it as a collapsible tree.