What this tool generates
Paste any JSON and the generator immediately produces TypeScript interface or type declarations. Each nested object becomes its own named interface. Arrays of objects have their element shapes merged — so keys that only appear in some elements are automatically marked as optional.
Mixed-type arrays (e.g. [1, "two"]) produce union types: (number | string)[]. Fields with a null value are typed as null; enable Nullable unknown to type them as unknown | null when you know the field will have a real type in production.
Options explained
- Root name — the name of the top-level interface or type alias. Defaults to
Root.
- interface vs type alias — both describe object shapes identically.
interface supports declaration merging; type is more flexible for unions. Either works for JSON-derived types.
- Export — prepends
export to every declaration so they can be imported in other files.
- All optional — adds
? to every field, useful when API responses may omit fields.
- Nullable unknown — types
null fields as unknown | null rather than plain null, indicating the real type is unknown from the sample.
Frequently Asked Questions
How do I generate a TypeScript interface from JSON?
Paste your JSON object or array into the input pane. The tool instantly generates TypeScript declarations — one named interface for each level of nesting. Configure the root name, keyword, and modifiers using the options bar, then copy or download the result.
What is the difference between a TypeScript interface and a type alias?
Both define the shape of an object and are interchangeable for JSON-derived types. interface supports declaration merging (two interface Foo blocks combine into one) and is the traditional TypeScript style for object shapes. type Foo = { ... } is more flexible — it can express unions, intersections, and mapped types. For simple API response types, choose whichever matches your codebase's style.
How are nested objects handled?
Each nested object generates its own named interface derived from the key name in PascalCase. For example, a user object with an address field produces interface User { address: Address; } and a separate interface Address { street: string; city: string; }. All interfaces are output together so you can paste them directly into your project.
How are arrays of objects handled?
When an array contains objects, the tool analyzes every element and merges their key sets. Keys present in every element are required; keys present in only some elements are automatically marked optional?. The field type becomes ElementType[] with the merged interface generated separately.
How are null values handled?
A field whose value is null in your JSON sample is typed as null by default. Enable Nullable unknown to type it as unknown | null — useful when you know the field will have a real value in production but is null in your test data. You can then replace unknown with the actual type.
What happens with non-standard key names (spaces, hyphens)?
Keys that are not valid TypeScript identifiers (e.g. my-field or Content-Type) are automatically quoted: "my-field"?: string. This produces valid TypeScript that can be accessed with bracket notation: obj["my-field"].
Does this tool send my JSON to a server?
No. All conversion happens entirely in your browser. Your JSON is never uploaded or transmitted anywhere — it never leaves your device.
How do I generate TypeScript types from JSON in code?
At the command line, quicktype is the most capable option: npx quicktype --lang typescript -o types.ts input.json. In VS Code, the Paste JSON as Code extension does the same inline. This browser tool is the fastest option for one-off conversions with no installation required.