JSON to TypeScript
Generate TypeScript interfaces from any JSON sample. Nested objects become named interfaces.
Runs in your browser Instant No signup, no tracking
About this tool
Paste a sample API response and get a set of exported TypeScript interfaces. Nested objects are extracted into their own named interfaces (based on the parent key, PascalCased). Arrays are typed from their first element. Integers and floats both become `number`; empty arrays become `unknown[]` so you can narrow them by hand. The generator is opinionated but predictable — read the intro on nulls before shipping the output to production.
Example
Paste the input on the left and you will get output like this:
Sample JSON
{
"user": {
"id": 42,
"name": "Ada Lovelace",
"isAdmin": true,
"roles": ["engineer", "author"],
"address": { "city": "London", "zip": "SW1A" }
}
}Resulting TypeScript
export interface Address {
city: string;
zip: string;
}
export interface User {
id: number;
name: string;
isAdmin: boolean;
roles: string[];
address: Address;
}
export interface Root {
user: User;
}How to use JSON to TypeScript
- Paste or type your JSON into the left pane.
- The TypeScript appears instantly in the right pane. Conversion runs in your browser — nothing is uploaded.
- Copy the result to your clipboard or download it as a file.
FAQ
- How are nullable fields typed?
- Explicit nulls in the sample produce the `null` type. If a field is sometimes missing and sometimes present, add `| undefined` yourself — a single sample can't infer optionality.
- Are unions merged across array items?
- No. Only the first array element is inspected. For polymorphic arrays, add a discriminant field and refine the union manually.
- Can I paste this straight into my project?
- Yes. The output is standard TypeScript — no runtime, no dependencies, works with strict mode.