JSON to TypeScript
Paste a JSON sample, such as an API response, to get matching TypeScript interfaces or type aliases, ready to copy into your code.
Your files stay on your device. Nothing is uploaded.
Step 1: Paste JSON
Step 2: Choose the style
Step 3: Copy the types
How to turn JSON into TypeScript types
-
Paste JSON
Paste a real example of the data, such as an API response.
-
Choose the style
Name the main type, and choose interface or type alias, optional nulls and readonly.
-
Copy the types
Copy the types or download a .ts file.
About this tool
Smart about arrays
Items in an array are merged into one type. A key that appears in only some items becomes optional (name?: string), and a value that is sometimes a number and sometimes text becomes a union.
Named nested types
Nested objects get their own named types from their keys, for example users becomes User, and identical shapes share one type instead of repeating.
A starting point
Types come from the sample you paste. If a field can be null or missing in other responses, add that, or tick "Treat null as optional".
Privacy
This tool runs in your browser, on your own device. Your files and text are not uploaded to our server and we cannot see them. When you close or reload this tab, they are cleared, along with the results.
Frequently asked questions
Interface or type alias?
Both work for object shapes. Interfaces can be extended and merged; type aliases can also name unions. Pick what your project uses.
What happens to empty arrays?
They become unknown[], because there is nothing to learn the item type from. Replace it with the real type.
Is my JSON uploaded?
No. It runs in your browser, so nothing you type or choose is sent anywhere.
My JSON has an error
Fix it first with the JSON formatter, which shows the line and column of the problem.
Related tools
- { JSON } JSON formatter Format, validate, minify and sort JSON.
- JSON › YAML JSON to YAML Convert JSON to clean, readable YAML as you type.
- JSON › CSV JSON to CSV Turn a JSON list of objects into a CSV table.
- JWT JWT decoder Read the header, claims and expiry of a JSON Web Token.
- SQL SQL formatter Format and beautify SQL for MySQL, PostgreSQL and more.
- /.*/ Regex tester Test regular expressions with live highlights and groups.
- XML › JSON XML to JSON Convert XML to JSON as you type, attributes included.
- v4 · v7 UUID generator Make random UUIDs (version 4 or 7), up to 100 at once.