JSON to TypeScript
Turn sample JSON into ready TypeScript interfaces: names from the keys, records in arrays merged, optional fields for missing keys, plus null and readonly as you choose.
Free, no sign-up
Your data stays on your device
Works offline after first open
The tool
Loading the tool…
How to use
- Paste sample JSON (more than one record is better).
- Type the root name and choose interface or type.
- Decide on optional fields for missing keys, readonly and export.
- Copy the code or download it as a .ts file.
Privacy & how it works
Processes your data in the browser and stores nothing.
- Engine: lightweight in-page code, no external libraries.
- Works offline after you open it once.
Frequently asked questions
How are nested types named?
From the key in PascalCase: address becomes Address, and items of a users array become User. Identical shapes reuse the same name.
When is a field optional (?)
When it appears in some objects of the same array but not in others.
Why do I get unknown[]?
The array is empty in your sample, so its item type is unknown. Add at least one item to the sample.
Related tools
JSON Schema GeneratorPaste sample JSON and get a ready JSON Schema (Draft 2020-12 or 07): types, required fields, nullable values and formats like email, date and uri, merged across many records.JSON Formatter & ValidatorPretty-print JSON or minify it to one line, sort keys alphabetically, validate it with the exact line, column and cause of any error, or escape and unescape JSON strings.JSON Viewer & JSONPath QueryBrowse JSON as a collapsible tree, search keys and values, and pull out what you need with a JSONPath query like $.items[?(@.price > 10)].name, copying any path or value.CSV to JSONConvert CSV or TSV to JSON: an array of objects, arrays or columns, with real numbers and booleans, and nested objects from headers like address.city. Arabic supported.