JSON to TypeScript Converter
Turn a JSON sample into TypeScript interfaces by inferring each value's type.
Enter your details below.
How to use
- Paste your JSON sample into the box.
- Click Convert.
- Copy the generated interfaces into your TypeScript code and adjust optional fields as needed.
About this tool
Paste a JSON sample and this tool walks through it recursively: objects become interfaces, arrays become element types, and strings, numbers and booleans become their matching types, with nested objects getting their own interfaces. It is a starting point for typing an API response, so check the result against the real data, especially for fields that are sometimes missing or sometimes null. Invalid JSON produces a clear error instead of a guess.
Frequently asked questions
What happens with an empty array?
It becomes unknown[], because an empty array gives no clue about its element type. Replace it once you know what the array holds.
Are nested objects handled?
Yes. Each nested object gets its own interface, named from its field, and the parent refers to it by that name.