JSON to TypeScript
Generate TypeScript interfaces from a JSON sample.
Runs in your browser Runs entirely in your browser. Nothing you put in it ever leaves your device.
Paste JSON, or drop a .json file here. Converts as you type.
Ready. Everything runs in this page.
Was this useful?
About this tool
Paste an API response and get interfaces you can drop straight into your project. Keys that only appear in some array items become optional, values with mixed types become unions, and nested objects get their own named interface.
How to use it
- Paste a representative JSON sample — the more complete, the better the types.
- Name the root type.
- Choose interfaces or type aliases, and whether properties should be readonly.
- Copy the result into your project.
Supported input
- Any valid JSON value
Privacy
Runs entirely in your browser. Nothing you put in it ever leaves your device. Everything happens in JavaScript on this page, so the tool keeps working even if you go offline after it has loaded — which is the simplest way to see for yourself that nothing is being sent. Read the full privacy information.
Questions
How does it decide a property is optional?
When the input is an array of objects, every item is inspected. A key present in some items but not others is marked with `?`, so a single sample of two records is usually enough.
What happens with null values?
A null becomes the `null` type, and a key that is sometimes null and sometimes a string becomes `string | null`.
Are the generated names stable?
Yes. Interface names come from the key path, so the same input always produces the same output — safe to commit and diff.
Related tools
-
JSON Formatter
Format, validate and inspect JSON.
Stays on your device
-
JSON to JSON Schema
Infer a JSON Schema from a sample document.
Stays on your device
-
JSON to CSV
Turn JSON into a spreadsheet-ready CSV file.
Stays on your device
-
JSON to YAML
Convert JSON into readable YAML.
Stays on your device