JSON to TypeScript
Generate TypeScript interfaces or types from JSON — with nested types, optional fields and union types.
100% private: everything runs in your browser and nothing is uploaded.
How to Convert JSON to TypeScript
No sign-up, no installation — it works right here in your browser.
- Step 1:Paste a representative JSON sample (an API response, a config file or a fixture) or click Load sample.
- Step 2:Set the root type name and choose interface or type alias, export, readonly and unknown options.
- Step 3:Copy the generated definitions into your project or download them as a .ts file.
JSON to TypeScript FAQ
How do I generate TypeScript interfaces from JSON?
Paste your JSON into the input box and the tool instantly generates TypeScript interfaces for it. The top-level object gets the root name you choose and every nested object becomes its own interface.
How are optional properties detected?
When an array contains several objects, the generator compares them. A property that is missing from at least one item is marked optional with ?, and a property whose values have different types gets a union type.
Should I use interface or type?
Both describe object shapes. Interfaces can be extended and merged, which suits public APIs and libraries; type aliases can express unions and mapped types. Pick whichever matches your codebase conventions — the tool supports both.
Why does an empty array become unknown[]?
An empty array gives no information about its elements. unknown[] keeps your code type-safe under strict mode and forces you to narrow the type; switch the option off if you prefer any[].
Is my JSON sent to a server?
No. Type generation happens entirely in your browser, so private API responses and internal data never leave your device.
Generate TypeScript Types from JSON Automatically
Writing TypeScript interfaces by hand for every API response is slow and error-prone, especially when payloads contain nested objects and arrays. This free JSON to TypeScript converter reads a sample of your JSON and generates accurate type definitions in a second: every nested object becomes its own named interface, arrays become typed lists, and primitive values are mapped to string, number, boolean or null. Names are derived from the property keys in PascalCase, and array element types are singularised, so addresses becomes Address and categories becomes Category.
When an array contains objects with different keys, the generator merges them into one interface and marks properties that are missing from some items as optional, while values that change type become union types such as string | null. You can choose interface or type alias declarations, add the export keyword, make every property readonly and use unknown instead of any for empty arrays to keep strict mode happy. Everything runs in your browser, so internal API payloads never leave your machine — paste, copy the result into your project and get autocomplete and type safety immediately.