Free · Instant · Runs locally

JSON to TypeScript

Paste any JSON — an API response, a config file — and get clean TypeScript interfaces with nested types, arrays, optional properties and unions detected automatically.

🔒 Conversion runs locally — your JSON never leaves the browser.

How to generate TypeScript types from JSON

📥

1. Paste JSON

Drop in an API response or any JSON document. It is parsed and validated instantly.

🧠

2. Types are inferred

Nested objects become their own interfaces; arrays are scanned so properties missing from some items become optional.

📋

3. Copy or download

Grab the generated interfaces (or type aliases) and paste them straight into your project.

Hand-writing types for a big API response is tedious and error-prone — this generator scans every object in every array, merges the shapes, marks missing keys optional, and unions mixed primitive types (string | number). Sub-objects get their own named interfaces so the output reads like hand-written code. Tidy the input first with the JSON Formatter, or compare two payloads with JSON Diff.

JSON to TypeScript FAQ

How are optional properties detected?

When converting an array of objects, the generator merges all item shapes. A key present in some items but not others becomes optional (name?: string), matching how you would type it by hand.

What happens with null values?

A field that is null in the sample becomes a union with null (string | null) when other samples show a type, or unknown when null is all the generator has seen.

Interfaces or type aliases — which should I use?

Functionally equivalent for object shapes. Interfaces merge declarations and read conventionally for API models; type aliases compose better with unions. The toggle outputs either style.

Is my JSON sent anywhere?

No — parsing and generation run entirely in your browser, so API responses with real data stay private.