Search tools

Find a tool by name or what it does.

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

Your TypeScript interfaces will appear here.

How to convert JSON to TypeScript online

  1. Paste your JSON

    Drop a JSON object, array, or value into the input. The matching TypeScript interfaces appear live as you type.

  2. Name the root

    Set the root interface name to whatever suits your code, such as User, ApiResponse, or Config.

  3. Choose the modifiers

    Toggle the export keyword and readonly properties so the output matches your project conventions.

  4. 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