JSON to TypeScript
Generate TypeScript interfaces from a JSON sample instantly.
ToolsSoup's JSON to TypeScript converter is a free online tool that generates TypeScript interfaces from a JSON sample in one click. It infers a type for every field, creates separate interfaces for nested objects, merges array items, and marks fields that aren't always present as optional. Everything runs in your browser — no uploads, no sign-up, and nothing ever leaves your device.
What is a JSON to TypeScript converter?
A JSON to TypeScript converter reads a sample of JSON — for example an API response — and produces matching TypeScript interfaces you can paste straight into your code. Instead of typing out every property and its type by hand, you get accurate type definitions in seconds, complete with nested interfaces and optional markers. It is a huge time-saver when you are integrating an external API or adding types to an existing codebase.
How to generate TypeScript from JSON online
Generating types with ToolsSoup takes just a few seconds:
- Paste a representative JSON sample into the input box on the left.
- Optionally set the name of the root interface (the default is Root).
- Click Convert, then copy the interfaces or download them as a .ts file.
How are optional fields and nested types inferred?
When your JSON is an array of objects, the converter merges every item to build one interface: a property that appears in some items but not others is marked optional with a question mark. Nested objects become their own named interfaces, and arrays become typed arrays such as string[] or a union like (string | number)[]. The result is a faithful set of types you can refine as needed.
Why use this JSON to TypeScript converter?
- 100% free with no ads, sign-up, or usage limits.
- Runs entirely in your browser — your data is never uploaded to a server.
- Generates separate interfaces for nested objects.
- Detects optional fields and infers array and union types.
- Copy the result or download it as a .ts file.
Frequently asked questions
Is this JSON to TypeScript converter free?
Yes. Every tool on ToolsSoup is completely free to use, with no account, sign-up, or hidden limits.
How does it decide which fields are optional?
When you provide an array of objects, the tool compares every item. A field present in only some of them is marked optional with a ? so your types match the real data.
Does it handle nested objects and arrays?
Yes. Nested objects are turned into their own named interfaces, and arrays are typed by their elements — for example Item[] for an array of objects, or (string | number)[] for a mixed array.
Can I rename the root interface?
Yes. Type any name into the Root interface field. If you leave it blank, the converter uses Root by default.
Is my data safe?
Absolutely. All conversion happens locally in your browser using JavaScript, so your JSON is never sent to or stored on any server.