JSON to TypeScript
Generate TypeScript interfaces or type aliases from JSON instantly. Optional fields, export keyword and reusable nested shapes. Runs 100% in your browser.
Runs locally · data never uploaded
Advertisement
How to use
What it does
Turn a JSON document into TypeScript type definitions. It handles objects, arrays, primitives, null and empty objects; nested objects become their own interface (or type), and with "Reuse types" identical shapes collapse into one reusable type.
Example
Input:
{
"user": { "name": "Alice", "age": 30, "tags": ["a", "b"] },
"active": true
}Without "Reuse types":
interface Root {
user: User;
active: boolean;
}
interface User {
name: string;
age: number;
tags: string[];
}With "Reuse types" on, several objects that share the same shape reuse a single interface.
Options
- Root name: the top-level type name, default
Root - All optional: appends
?to every field - Export keyword: prefixes types with
export - Style: interface or type
- Reuse types: merge identical shapes
FAQ
Q1.What if array elements have different types?
A union is produced, e.g. `(string | number)[]`; a uniform array becomes `T[]`. An empty array infers as `unknown[]`.
Q2.How is a null field represented?
A field whose value is `null` gets the type `null`. Enable "All optional" if you also need to tolerate missing keys.
Q3.Can I copy the output directly?
Yes, the output is standard TS. Nested objects are split into their own types, and identical deep shapes are merged when reuse is enabled.
Q4.Is my data uploaded?
No. Parsing and generation happen entirely in your browser, and the tool works offline.
Advertisement