About this tool
Paste a real API response and get interfaces you can drop into your code. Fields that are missing from some array items are marked optional.
Generating TypeScript types from real data
Writing TypeScript interfaces by hand for a large API response is slow, and it is easy to miss a field or get a type wrong. Generating them from a real example gives you a solid starting point in seconds. Paste a response from the API you are working with, and the tool creates interfaces that match its shape, including nested objects and arrays of objects.
When the input is an array, the generator looks at every item rather than just the first. If a field appears in some items but not others, it is marked as optional, which matches how many APIs behave in practice. A field that is null in some items and a string in others becomes a union such as string | null, while a field that is only ever null is typed as null, since a single example cannot show what type it has when it is present.
Treat the output as a draft to review. One sample cannot show every possibility, so check the API documentation for fields that can be null, optional fields that happened to be present, and string fields that are really limited to a few values, which are better typed as a union of literal strings. Rename the generated interfaces to match your project's conventions, and consider whether dates should stay as strings or be converted when the data is parsed. Using a larger and more varied sample usually produces more accurate types. Because the tool runs in your browser, you can safely paste responses that contain real user data. Pair the types with runtime validation if the data comes from a source you do not control.
How to use it
- Paste your text into the input box, or open a file from your device.
- Adjust the options. The result updates instantly.
- Copy the result, or download it as a file where offered.
Questions
How are optional fields detected?
If a key is missing from some objects in an array, it is marked with '?'.
What type does null get?
A field that is only ever null becomes 'null'; mixed values become a union such as 'string | null'.
Last reviewed 16 October 2026.
