JSON to TypeScript types
Infer TypeScript interfaces or types from a JSON sample.
Loading the tool…
What it does, how to use it, and questions
What it does
Inferring TypeScript types from a JSON sample turns nested objects into interfaces or type aliases and arrays into typed arrays.
Optional vs required is a guess from a single sample: keys present are required in the output unless marked otherwise.
How to use it
- Paste JSON.
- Choose interface or type alias output.
- Copy the TypeScript.
Things to watch for
- A single sample cannot prove a field is optional. Add
?yourself when the API omits keys. - Numbers stay
number; big integers that lost precision in JSON.parse are already wrong before codegen.
Questions
- Does it use the JSON Schema tool?
- No. It infers from a sample. Use Schema codegen when you already have a schema.
- Are nested objects named?
- Nested object types are inlined or given generated names depending on depth.
- null handling?
nullbecomesnullin unions when mixed with other types in an array sample.- Is the JSON uploaded?
- No.