Code generators
JSON to TypeScript Generator
Paste a JSON response and get typed, ready-to-paste TypeScript. Array items are merged so optional fields are detected, nested objects become named interfaces, and mixed types become honest unions.
- Runs 100% in your browser
- No signup · No uploads
- Free, unlimited use
JSON sample
Examples: User object · List with optional fields — ⌘/Ctrl + Enter converts · drop a file to load it · processed locally
TypeScript
Output is read-only. Use Copy, Download or Share to move it out.
How to use the json to typescript tool
-
Paste a real response
Use a payload that includes the optional and nullable fields you actually see in production — the more representative, the better the inferred types.
-
Name your root type
Give the root type the name it has in your codebase (User, Order, ApiResponse) and choose interfaces or type aliases to match your style guide.
-
Copy into your project
Paste the result into your types file. For runtime validation, pair it with a JSON Schema or a runtime validator such as Zod.
What makes this one different
- Merges array element shapes and marks non-universal keys as optional
- Unions for mixed types (string | number, string | null) rather than silent any
- Nested objects named from their key path (Address, Evidence, …)
- Interface or type-alias output, with a custom root name
- Optional ISO date detection to flag timestamp fields
Privacy by architecture: this page contains no analytics that receive your input, and the conversion code runs in your tab. You can disconnect from the network after loading and keep working.
JSON to TypeScript — frequently asked questions
How are optional fields detected?
When the input is an array of objects, each property is checked across every item. A key missing from some items is marked optional with ?, and keys present everywhere stay required.
How do nullable fields become types?
A null is treated as a type of its own, so a field that is sometimes a string and sometimes null is typed string | null — an honest type rather than a lie your compiler trusts.
Interfaces or type aliases — which should I pick?
Interfaces are the more common convention and merge well in declarations; type aliases read better for unions and intersections. Functionally, for generated data shapes, either works — match your existing codebase.
Can it generate Zod or other runtime schemas?
Not directly. Generate the JSON Schema from the same payload and derive a validator, or write the Zod schema by hand and use these interfaces for the static side. Types describe shape at compile time; validators protect you at runtime.
Does this work for large API responses?
Yes. Paste or drop the JSON file — nesting is inferred recursively. Very large payloads are limited by browser memory rather than the generator itself.
Related tools
Searching for “json to ts”, “json to interface”, “quicktype alternative”? You are in the right place — browse all 19 tools.