JSON to TypeScript
JSON
TypeScript
ExampleAbout
TypeScript interfaces define the expected shape of data at compile time, catching type errors before code runs. Generating interfaces from sample JSON is a fast way to bootstrap type definitions when integrating with external APIs or migrating a JavaScript codebase to TypeScript.
How to use
1.
Paste JSON into the JSON panel
2.
Optionally change the Interface name, or turn on Add export keyword to get an exported declaration - the TypeScript is generated as you type
3.
Copy it into your project, or download it as a .ts file
Common uses
▸
Typing API response objects when building TypeScript applications
▸
Generating interfaces for configuration files or stored data structures
▸
Bootstrapping types from sample data before writing full models
Similar tools
Frequently asked questions
Does it handle nested objects?
Nested objects generate inline object type literals inside the root interface (e.g., address: { street: string; city: string; }), and arrays generate typed array properties (e.g., string[], { id: number; name: string; }[]).
What happens with null values?
A null value is typed as null and combined with any other type seen for the same property, e.g. string | null. A property that is null in every sample is typed as just null - update it once you know the actual type.
Can I use this with API responses?
Yes - paste a raw JSON response. An object at the top level becomes an interface; an array or a single value becomes a type alias instead, such as type Root = { id: number }[]. The more varied the sample, the better the optional keys and unions match the real data.
Is my data sent to a server?
Type generation runs entirely in your browser. No JSON is uploaded or stored.
Does it handle arrays of mixed types?
Mixed-type arrays are typed as a union (e.g. (string | number)[]). Arrays of objects are merged into one object type: a key missing from some elements is marked optional (key?: type), and a key whose type differs between elements gets a union.