JSON to TypeScript Converter
What is JSON to TypeScript Converter
This tool turns any JSON into clean TypeScript interfaces, right in your browser. It walks the whole structure, creates a named interface for every nested object, infers the type of each field, and types arrays from their contents. When objects in an array do not all share the same keys, the missing ones are marked optional so the result compiles against real-world data.
How to use
- Paste your JSON into the input field on the left.
- Name the root interface if you want something other than Root.
- Read the generated TypeScript on the right, updated as you type.
- Click Copy and drop the interfaces straight into your code.
When to use it
Got a JSON response from an API and no types for it? Paste it in and you get ready-to-use interfaces in seconds. Feed it a list of users where one record is missing an avatar field and the converter marks that field optional (avatar?: string), so your types match what the endpoint actually returns instead of a guess.
Frequently asked questions
How are optional fields detected?
When you paste an array of objects, the converter compares the keys across every item. Any key that is not present in all of them becomes optional (marked with ?). Keys present in every item stay required.
Does my JSON get sent to a server?
No. The whole conversion runs in your browser with JavaScript. Nothing is uploaded, so private API payloads and internal data never leave your machine.
How does it handle nested objects and arrays?
Each nested object becomes its own named interface, derived from the key name. Arrays are typed from their items: number[], a merged interface for arrays of objects, or a union like (string | number)[] for mixed content.
What happens with null or empty arrays?
A null value is typed as null and an empty array becomes any[], since there is no sample to infer an element type from. Fill in a representative example to get a precise type.
Can I share this tool with my JSON pre-filled?
Yes. The URL updates automatically as you type. Copy it from the address bar or use the Copy link button, and anyone who opens the link sees your exact JSON already converted.
Related tools
AES Text Decryption
Decrypt AES-256 encrypted text with your password in your browser. Free, private, and fully offline. No data leaves your device.
AES Text Encryption
Encrypt text with a password using AES-256 in your browser. Free, private, and fully offline. Nothing is sent to a server.
Aspect Ratio Calculator
Calculate aspect ratios, find a missing width or height, and resize images or video while keeping the same proportions. Free and instant.