JSON to TypeScript Interface Generator
Paste JSON and instantly generate TypeScript interfaces with auto-detected types
Paste any JSON and get typed TypeScript interfaces back — nested objects, arrays, unions, tuples, all handled automatically. Pick between interface and type, toggle optional, readonly, or export, and download the result as a .ts file. And everything runs in your browser. Nothing gets uploaded.
How It Works
The parser walks through every key in your JSON, figures out whether the value is a string, number, boolean, array, or nested object, and builds a matching TypeScript interface. Nested objects get their own named interfaces based on the key name — so "address": {...} becomes an Address interface automatically. Arrays are checked for consistency: if every item has the same shape, you get a clean typed array. Mixed types produce a union.
Examples
Simple API User Response
You hit a /users endpoint and need types for the response.
{
"id": 42,
"name": "Sarah Chen",
"email": "[email protected]",
"active": true
}
interface Root {
id: number;
name: string;
email: string;
active: boolean;
}
Nested E-Commerce Order
An order object with a shipping address and line items — the kind of thing that is painful to type by hand.
{
"orderId": "ORD-7891",
"total": 89.95,
"shipping": {
"street": "12 Elm St",
"city": "Portland",
"zip": "97201"
},
"items": [
{ "sku": "A1", "qty": 2 }
]
}
interface Root {
orderId: string;
total: number;
shipping: Shipping;
items: Item[];
}
interface Shipping {
street: string;
city: string;
zip: string;
}
interface Item {
sku: string;
qty: number;
}
Config File with Mixed-Type Arrays
A settings blob where one array holds strings and numbers — tuple detection shines here.
{
"theme": "dark",
"retries": 3,
"viewport": [1920, 1080],
"flags": ["beta", "debug"]
}
interface Root {
theme: string;
retries: number;
viewport: number[];
flags: string[];
}
Who Uses This
Generating interfaces for API responses so autocomplete actually works and typos get caught at compile time.
Creating shared types for Node.js services that consume JSON payloads from other microservices.
Learning how JSON structures map to TypeScript types without manually writing every interface from scratch.
Typing JSON datasets before loading them into TypeScript-based dashboards or processing scripts.
Common Mistakes
Trailing commas, single quotes, or unquoted keys will break the parser. Run your JSON through a validator first if you copied it from logs or a console. The status bar at the bottom shows the exact error position.
If your JSON sample only has one item in an array, the tool can't know that other items might have extra fields. Paste a response with several items so the generated types cover all possible properties.
The default root name is "Root" — fine for quick tests, not great in a real codebase. Change it to something meaningful like UserResponse or OrderPayload before copying the output into your project.
Technical Details
- Processing: 100% client-side — your JSON never leaves the browser
- Browser Support: Chrome, Firefox, Safari, Edge
- Output Formats: TypeScript
interfaceortypealias - Nested Depth: No limit — deeply nested JSON is handled recursively
- Download: Generated code exports as a
.tsfile
Frequently Asked Questions
What is the difference between interface and type in TypeScript?
Interfaces can be extended and support declaration merging — if two interfaces share a name, TypeScript combines them. Types are more flexible: they handle unions, intersections, and tuple aliases. For converting JSON, the output is basically identical either way. Pick interface if you want extendability, type if you need unions or mapped types later.
Can I convert JSON to TypeScript without installing anything?
Yes. This runs entirely in your browser — no npm packages, no CLI tools, no VS Code extensions needed. Paste your JSON, grab the output, done. It works on any device with a modern browser.
How does the tool handle null values in JSON?
A null value becomes null in the TypeScript type. If a field is sometimes a string and sometimes null, you get a union like string | null. This matches how real API responses work — fields that might be missing come through as null.
Is my data safe when using this JSON to TypeScript converter?
Completely. The conversion happens in JavaScript right inside your browser tab. No data gets sent to any server. You can disconnect from the internet and it still works — that's the proof.
Why does my generated interface show unknown[] instead of a proper type?
That happens when your JSON has an empty array like []. The tool can't guess what type belongs there because there are no items to inspect. Add at least one example item to the array in your JSON, and the type will be inferred correctly.