JSON to TypeScript
Paste JSON and get typed TypeScript interfaces, with nested objects, arrays, optional fields, and null handled for you.
Interfaces are generated live as you type. Nothing leaves your browser.
Options
TypeScript
How to convert JSON to TypeScript online
Paste your JSON
Drop a JSON object, array, or value into the input. The matching TypeScript interfaces appear live as you type.
Name the root
Set the root interface name to whatever suits your code, such as User, ApiResponse, or Config.
Choose the modifiers
Toggle the export keyword and readonly properties so the output matches your project conventions.
Copy the interfaces
Copy the generated TypeScript to your clipboard or download it as a .ts file.
Why use this tool
Nested interfaces
Every nested object becomes its own named interface instead of an inline type, so deep JSON reads as a clean set of definitions.
Arrays and unions
Array elements are merged into a single element type, and mixed elements collapse into a union such as (string | number)[].
Optional and null fields
A field missing from some objects in a list is marked optional with a question mark, while explicit null values are kept in the type.
Export and readonly toggles
Add the export keyword to every interface and mark properties readonly with one click, to match your codebase.
Configurable root name
The top-level interface is named from your input, and repeated object shapes are deduplicated into a single shared interface.
Runs entirely in your browser
Everything happens on your device. Nothing is uploaded, so private payloads and API responses stay local.
About this tool
This tool turns a JSON sample into a set of TypeScript interfaces. Paste an object, an array, or a bare value, and it walks the structure to infer a typed shape: strings, numbers, and booleans become primitive types, nested objects become their own named interfaces, and arrays become element types with a union when the elements differ.
It handles the awkward parts of real API data. When a list contains objects that do not all share the same keys, the missing keys are marked optional; when a value is explicitly null, that null is kept in the type rather than silently dropped. Repeated object shapes are collapsed into one shared interface so the output stays short. A top-level array produces a named type alias over its element interface, and invalid input shows the parser message inline instead of a broken result.
It pairs well with the rest of your workflow. Tidy a messy payload first with the JSON formatter, turn a spreadsheet export into typed records with CSV to JSON, or round-trip a config through JSON to YAML. Because the whole thing runs in your browser, response bodies that name internal services or tokens never leave your machine.
Frequently asked questions
- How does it infer the types?
- It reads a JSON sample and derives the shape from the values it finds. Objects become interfaces, arrays become element types, and primitives map to string, number, or boolean. The result updates live as you edit the input.
- How are arrays with mixed types handled?
- All elements of an array are merged into one element type. If they differ, the element type becomes a union, for example (string | number)[]. Arrays of objects merge into a single interface whose fields cover every element.
- What is the difference between optional and null fields?
- A field that is absent from some objects in a list is marked optional with a question mark. A field that is present but set to null keeps null in its type. That way an absent key and a null value stay distinct.
- What happens if my JSON is invalid?
- The tool shows an inline error with the parser message instead of crashing, and clears it the moment the input parses again. Empty input shows a neutral placeholder rather than an error.
- Is my data uploaded anywhere?
- No. Everything runs in your browser. Your JSON never leaves your device, is never sent to a server, and is not stored or logged.
Related tools
JSON Formatter & Validator
Pretty-print, minify, or explore JSON as a collapsible tree, with syntax errors shown inline.
CSV to JSON
Paste CSV and get a clean JSON array of objects, with header detection and automatic number and boolean typing.
JSON to YAML
Convert JSON to YAML and YAML back to JSON, in both directions, with your choice of indentation.
API Key Generator
Generate cryptographically random API keys and tokens in hex, base62, or base64url, with control over length, an optional prefix, and bulk output.
ASCII Table Reference
The full ASCII character set with decimal, hex, octal, binary, and HTML codes. Search by code, character, or name.
Atbash Cipher
Mirror the alphabet so A swaps with Z, B with Y, and so on. Atbash is its own inverse, so one field both encodes and decodes as you type.