JSON to TypeScript
export interface Root {
id: number;
name: string;
active: boolean;
tags: string[];
profile: Profile;
}
export interface Profile {
age: number;
city: string;
}Related external tools
Some links are affiliate links.
Related tools
Turn JSON into TypeScript types in one step. Paste an API response or any JSON object and instantly get clean interfaces or type aliases, with nested objects, arrays and optional fields handled for you. Everything runs in your browser — nothing is uploaded.
How to use
- Paste your JSON into the input box.
- Set the root type name and choose interface or type, plus how nulls are handled.
- Copy the generated TypeScript into your project.
How the types are inferred
Each object becomes its own interface, and nested objects get their own named interfaces. Arrays of objects are merged into a single shape, where keys that are missing from some items become optional. Values that are null are turned into a nullable type, or an optional field if you prefer.
Features
Nested objects
Deeply nested JSON is split into clear, separate interfaces that reference each other.
Merged array shapes
Arrays of objects are combined into one type, with optional fields where items differ.
Optional & nullable fields
Choose whether null values become a nullable type or an optional property.
interface or type
Output named interfaces or type aliases to match your codebase style.
Custom root name
Name the top-level type whatever you like, such as User or ApiResponse.
Common use cases
Typing API responses
Paste a sample response and get types to use across your app.
From mocks & fixtures
Generate types from example data so your code stays type-safe.
Config & data files
Create types for JSON config or content files in seconds.
Learning TypeScript
See how real JSON maps to TypeScript interfaces and unions.
Notes & tips
- Types are inferred from the sample you paste, so include all the fields you care about.
- An empty array becomes unknown[], since there's no item to infer from.
- Review the output for unions and optionals before using it in production.
- Everything runs on your device — nothing is sent to a server.
Frequently asked questions
- Does it handle nested objects?
- Yes. Each nested object becomes its own named interface, and the parent references it by name.
- How are arrays typed?
- Arrays of objects are merged into a single interface; keys missing from some items become optional. Arrays of mixed primitives become a union, like (string | number)[].
- How are null values handled?
- By default a null becomes a nullable type. You can switch to treating null as an optional property instead.
- Should I use interface or type?
- Both work; pick what matches your codebase. Interfaces are common for object shapes, while type aliases are flexible for unions.
- Is my JSON uploaded?
- No. The generator runs entirely in your browser. Nothing is sent to a server and there is no sign-up.