JSON to TypeScript Converter
Paste any JSON and get clean TypeScript interfaces or types right away. Nested objects become their own interfaces, arrays merge into one shape, and missing keys turn optional. Free, no signup, runs in your browser.
How to convert JSON to TypeScript
Paste or Upload Your JSON
Drop in a JSON object or an API response, or upload a .json file. The TypeScript appears right away.
Pick interface or type
Choose whether to output interfaces or type aliases to match your codebase.
Set the Options
Toggle export, readonly, and null-optional so the generated types drop straight into your project.
Copy or Download
Copy the TypeScript to your clipboard or download it as a .ts file. Nothing is ever uploaded.
Stop Hand-Typing Types From API Responses
When you wire up a new API, the tedious part is writing the TypeScript to match. You copy a sample response, type out every field, guess at the right types, and chase down the nested objects. Miss one and the compiler complains, or worse, it does not and you get a runtime surprise. This JSON to TypeScript converter does that grunt work in a second, and it handles the awkward shapes a quick hand-typed interface usually gets wrong.
How the JSON to TypeScript conversion works
Paste a JSON object and the tool walks the whole structure and writes the matching types as you type. Every value is mapped to its TypeScript type, so a string stays a string, a number stays a number, and a boolean stays a boolean. The output appears in a second pane with syntax colors, ready to copy or download as a .ts file. Nothing is sent to a server, the parsing happens on each keystroke in your browser.
interface or type, and the options that shape it
You control the output. Switch between interface and type to match your project style, toggle the export keyword so the types are ready to import, and turn on readonly when the data should not be mutated. There is also a null-optional switch that marks any field that can be null with a question mark instead, which is handy when an API returns null for absent values.
How it handles arrays, nested objects, and optionals
This is where hand-typed interfaces fall apart. Nested objects become their own named interfaces instead of one giant inline blob, so the result reads cleanly and the pieces are reusable. Arrays of objects are merged into a single shape, and if a key appears in only some items it is marked optional. Mixed-type arrays become a union like (string | number)[], and two objects with the same shape reuse one interface instead of duplicating it.
What to check before you trust the types
The types are inferred from the exact JSON you paste, so they are only as complete as your sample. If a field is missing from your example, or an array happens to hold only numbers when it can also hold strings, the generated interface will not know. Paste a representative response, ideally one with every field populated, and treat the output as a strong first draft you can tighten by hand.
Why Use Our JSON to TypeScript Converter?
Interface or Type
Generate TypeScript interfaces or type aliases from the same JSON, whichever your project prefers.
Nested Interfaces, Named
Nested objects become their own named interfaces instead of one inline blob, so the result is clean and reusable.
Array and Union Inference
Arrays of objects merge into one shape, and mixed-type arrays become a proper union type.
Optional Field Detection
When a key appears in only some array items, it is marked optional with a question mark automatically.
export and readonly
Toggle the export keyword, readonly fields, and null-optional handling to match your house style.
Live and Color Coded
Both panes are syntax highlighted and update as you type, so you see the result instantly.
Paste, Upload, or Drop
Type JSON in, paste it, or drop a .json file straight from your computer.
Runs in Your Browser
Even private API payloads stay on your machine. Nothing is uploaded, logged, or stored.
Similar Tools
More Developer tools you might find useful.
Frequently Asked Questions
Common questions about converting JSON to TypeScript.
Does it generate interfaces or types?
Both. Use the toggle to switch between TypeScript interfaces and type aliases. The rest of the output, including nested shapes and optionals, works the same either way, so you can match whatever your codebase uses.
How are nested objects handled?
Each nested object becomes its own named interface instead of one large inline definition. That keeps the output readable and lets you reuse the smaller interfaces elsewhere in your code.
What about arrays and mixed-type arrays?
Arrays of objects are merged into a single interface that covers every key seen. Arrays with mixed value types become a union, for example (string | number)[], so the type reflects everything the array can hold.
Are optional fields detected automatically?
Yes. When a key appears in some array items but not others, it is marked optional with a question mark. You can also turn on null-optional so any field that can be null is treated the same way.
Can I make the fields readonly?
Yes. Turn on the readonly option and every property gets the readonly modifier, which is useful for data that should not be mutated after it is loaded.
Does my JSON get uploaded anywhere?
No. The whole conversion runs in your browser on your own device. Nothing is sent to a server, logged, or stored, so it is safe for private API responses.
Will the generated types be complete?
The types are inferred from the exact JSON you paste, so they are only as complete as your sample. If a field is missing from your example it will not appear. Paste a representative response and treat the output as a strong first draft.
Is this JSON to TypeScript converter free?
Yes, it is completely free with no signup and no limits. Everything runs in your browser, so your data stays on your device and is never sent to a server.