JSON to TypeScript
Convert JSON to TypeScript interfaces instantly. Free online JSON to TS type generator with nested object support.
Output will appear here...
What is JSON to TypeScript?
TypeScript interfaces define the shape of data objects with type annotations. Converting JSON to TypeScript interfaces automatically generates type definitions from real data, saving you from writing them by hand. This is especially useful when working with APIs — paste a sample JSON response and get a ready-to-use TypeScript interface.
How to Use
- Paste your JSON data (object or array) in the input area
- The TypeScript interface is generated instantly in the output panel
- Nested objects become separate interfaces with auto-generated names
- Optional fields are marked with ? when the input data is ambiguous
- Copy the generated interface code into your TypeScript project
Examples
Simple object to interface
Nested object with array
Related Tools
JSON Formatter & Minifier
Format, beautify, and minify JSON online. Free JSON formatter with syntax validation and error highlighting.
JSON to CSV Converter
Convert JSON data to CSV format instantly. Free online JSON to CSV converter with automatic header detection and nested object flattening.
YAML to JSON Converter
Convert YAML to JSON and vice versa. Free online YAML/JSON converter with syntax validation and pretty-print.
CSV to JSON Converter
Convert CSV to JSON format online. Free tool with support for custom delimiters, headers, and pretty-print output.
Frequently Asked Questions
How does it determine the TypeScript types?
The tool inspects each value in the JSON and maps it to the appropriate TypeScript type: strings become string, numbers become number, booleans become boolean, null becomes null, arrays become T[], and objects become nested interfaces.
What if the JSON has mixed types in an array?
When an array contains mixed types (e.g., [1, "two", true]), the tool uses a union type (string | number | boolean)[]. When all items have the same structure, it extracts a common interface for the array items.
Can I customize the interface name?
The default interface name is RootObject for the top-level object. Nested interfaces are named based on their parent key (e.g., User for a field named "user"). You can rename them after copying into your project.