JSON to TypeScript interface generator
Generate TypeScript interfaces from JSON. Nested objects, arrays and optional fields are inferred. Runs in your browser.
Runs 100% in your browserHow to convert JSON to TypeScript
- Paste your JSON. Paste a JSON object or array — a sample API response works well.
- Name the root. Optionally rename the root interface.
- Copy the interfaces. Copy the generated TypeScript into your project.
About JSON to TypeScript
Typing an API response by hand is tedious and error-prone. Paste a representative sample and get a set of interfaces that match its shape, ready to drop into your codebase and refine. The generator merges every object in an array so optional fields are caught, and names nested interfaces from their keys. Need Go instead? Use the JSON to Go generator.
Frequently asked questions
- It walks your JSON and builds TypeScript interfaces: objects become named interfaces, arrays become typed arrays, and arrays of objects are merged into one interface. A key missing from some objects in an array is marked optional with
?. - Each nested object gets its own interface named after its key (singularised for array elements), so
users: [...]produces aUserinterface. - Mixed types become a union (e.g.
string | number); a value that's only ever null becomesnull. Empty arrays becomeany[]. - No — inference runs entirely in your browser.