About this tool
Convert JSON objects recursively into type-safe TypeScript interfaces or type statements with formatting options.
JSON to TypeScript converts a pasted JSON object into exported TypeScript declarations, walking the structure recursively and giving every nested object its own named interface instead of an inline shape. Primitives are typed from the value's runtime type — string, number, boolean — while null becomes any, and you can switch the output between `export interface Name { }` and `export type Name = { }` and turn trailing semicolons on or off. It is for frontend and Node developers who have a sample API response and want typed models for it in seconds.
Open JSON to TypeScript on AltFTool — it loads instantly in your browser.
Paste your code or data sample into the workspace.
Pick the format, conversion, or analysis you need.
Copy the polished result straight back into your project.
Every nested object is hoisted into its own named, exported declaration so you can import and reuse the inner shapes.
Children are emitted before the root type that references them, so the file reads top-down from the smallest shape up.
Two different objects that map to the same interface name get a numeric suffix, so the output always compiles.
It reads the first element of the array and builds one interface from it, named after the key with an Item suffix, then types the field as that interface followed by []. If later elements have extra keys, they will not appear, so pass a representative first record.
null is emitted as any, because a single null tells the converter nothing about what the field holds when it is populated. Replace the null with a sample value in your input if you want a real type, or tighten it to a union by hand afterwards.
No — every key in your JSON becomes a required property with no question mark, since the sample only shows what was present. Add ? to any field your API can legitimately omit before you rely on the type.
Yes, a single dropdown switches the whole output between `export interface Name {` and `export type Name = {`, and the semicolon checkbox controls whether each property line ends in a semicolon or nothing, matching either Prettier default.