JSON to TypeScript
Paste JSON and get TypeScript interfaces, including nested objects and arrays.
TypeScript adds static types to JavaScript. Data from outside your code, like an API response, needs a type that describes its shape. This tool writes that type from a JSON sample, so you don't have to type it out field by field.
Because the types come from real data, the field names and types match what the API sent. Check them before use, since one sample can miss fields that are sometimes absent or null.
API development
Type an API response from a sample payload
Data modeling
Start a type definition from an example record
Migration
Type existing JSON config files
Prototyping
Skip writing first-draft types by hand
How do I convert JSON to TypeScript?
Paste your JSON into the input field and the TypeScript appears in the output. You can change the interface name and make properties optional or required.
What types are supported?
The tool detects string, number, boolean, null, arrays, and objects. For arrays, it takes the type from the first element, and an empty array becomes unknown[]. Each nested object gets its own named interface, such as Address for an address key, and the parent property refers to it by name.
Can I generate optional properties?
Yes. Turn on the 'Optional Properties' switch and every property gets a ? modifier. Use it for API responses where fields can be missing.
Should I use type or interface?
Both work for plain object shapes. Use 'interface' when you plan to extend the type. Use 'type' when you need unions or intersections. The tool outputs either.
Private by default
Conversion runs in your browser. Your JSON is never sent to a server.
Related tools
JSON Formatter
Format JSON online in your browser. Paste or upload JSON to tidy it with 2 or 4 space indents, find syntax errors, minify it or browse it as a collapsible tree.
JavaScript to JSON
Convert JavaScript object literals to valid JSON
JSON Merge
Merge two JSON objects online with a deep or shallow strategy and choose how arrays combine. Useful for config files and API responses. Free, no signup.