JSON to TypeScript
Paste JSON — get TypeScript interfaces as you type. Nothing leaves your browser.
› More options & type detection
JSON to TypeScript example
Turn an API response into TypeScript interfaces you can use with fetch, axios or any client. Each JSON object becomes an exported interface, nested objects and array items get their own interface, and fields missing from some items become optional.
{
"id": 42,
"login": "ada",
"name": "Ada Lovelace",
"email": null,
"createdAt": "2026-10-20T09:30:00Z",
"plan": {
"name": "pro",
"seats": 5
},
"repos": [
{
"id": 1,
"fullName": "ada/engine",
"private": false,
"stars": 12,
"topics": [
"math",
"history"
]
},
{
"id": 2,
"fullName": "ada/notes",
"private": true,
"stars": 0,
"topics": [],
"archivedAt": "2026-01-01T00:00:00Z"
}
]
}export interface User {
id: number;
login: string;
name: string;
email: null;
createdAt: string;
plan: Plan;
repos: Repo[];
}
export interface Plan {
name: string;
seats: number;
}
export interface Repo {
id: number;
fullName: string;
private: boolean;
stars: number;
topics: string[];
archivedAt?: string;
}
- Interfaces only, by default
- With “Interfaces only” on you get plain interfaces and no runtime code. Turn it off to also generate a Convert class whose toUser function parses a JSON string and checks it against the types at runtime.
- Optional fields from your samples
- archivedAt is only in the second repo, so it becomes archivedAt?: string. Paste several real responses, as an array or JSON Lines, so every optional field is found.
- null and empty arrays
- email is null in the only sample, so its type is null. Paste a sample where it has a value to get string | null. topics is empty in one repo, but the other repo has strings, so it is still string[].
- Strings stay strings
- createdAt stays string, matching what JSON.parse gives you. Options switch to type aliases instead of interfaces, readonly members, or unknown instead of any.
Convert JSON to any language
The same smart type inference, 28 output formats.
Types that match your real data
Built on the open-source quicktype engine, with quieter defaults and a friendlier editor.
- Optional fields detected
- Fields that are missing or null in some items become optional automatically.
- Merge many samples
- Paste JSON Lines or an array — every example contributes to one accurate type.
- Paste anything
- JavaScript objects, trailing commas, single quotes and comments are repaired for you.
- Sensible defaults
- No surprise enums or date classes — turn detection on only when you want it.
- Every option, every language
- All of TypeScript’s generator settings, from naming style to framework annotations.
- Private & instant
- Runs in a background thread in your browser. Share links keep data in the URL only.
Frequently asked questions
How do I convert JSON to a TypeScript interface?+
Paste your JSON on the left and the interfaces appear on the right as you type. Set the root name under Type name, then copy the code or download it as a .ts file.
Do the interfaces check my data at runtime?+
No. Interfaces only describe the shape for the compiler. Turn off “Interfaces only” to add a Convert class that validates JSON when you parse it, or use the JSON to Zod converter to get schemas you can call .parse() on.
Can I get type aliases instead of interfaces?+
Yes. Turn on “Use types instead of interfaces” in the options to generate export type User = { … } instead.
What if my samples have different fields?+
Paste several samples as JSON Lines (one JSON value per line) or as an array of objects. They are merged into one type, and fields missing from some samples become optional.
Can I paste a JavaScript object from the console?+
Yes. Unquoted keys, single quotes, trailing commas and comments are repaired automatically before the types are generated.
Is my data uploaded?+
No. The conversion runs entirely in your browser, in a background thread. Nothing is sent to a server.
Why don’t I see enums or date types?+
By default, string fields stay strings so the output matches your JSON exactly. Turn on “Detect enums” or “Detect dates” under Options to generate enum and date types.
Code generation uses quicktype (Apache-2.0 license).