Converters tool
✦ Browser-firstJSON to TypeScript
Generate TypeScript interfaces or types from a JSON sample.
About this tool
Turn any JSON sample into clean TypeScript interfaces or type aliases, with nested objects, arrays, unions and optional properties inferred automatically.
How to use the JSON to TypeScript
- Paste a representative JSON sample.
- Set the root name and choose interface or type.
- Copy the generated TypeScript.
Common uses
- Typing API responses
- Bootstrapping data models
- Documenting JSON payloads
JSON to TypeScript questions
How are optional properties detected?
If a key appears in some array items but not others, it is marked optional.
What about null values?
They become the null type. Combine samples with real values to see unions.
Is one sample enough?
The types reflect only your sample, so use a payload that shows the variety you expect.