JSON to TS
JSON → TypeScript interface
export interface User {
id: number;
name: string;
active: boolean;
tags: string[];
}
export interface Post {
id: number;
title: string;
views: number;
pinned?: boolean;
}
export interface Root {
user: User;
posts: Post[];
}What is JSON to TS?
Infer TypeScript interfaces from a sample JSON object. Handles nested objects (becoming nested interfaces), arrays of objects (merged into a single interface with optional fields for keys that vary), and primitive types. Produces clean, copy-pasteable TypeScript that you can drop into a types file.
How do I use JSON to TS?
- Paste sample JSON.
- Set the root type name.
- Copy or download the generated TypeScript.
When should I use JSON to TS?
JSON to TS speeds up API-client scaffolding. For Python's TypedDict equivalent, use JSON to Python. For producing a full validator (not just a type), use a schema library like Zod — this tool emits types only.
How accurate are the generated types?
Very — we infer union types when arrays contain mixed shapes, mark optional fields that appear in some but not all objects, and handle null correctly.
Does it generate interfaces or type aliases?
You choose — interfaces by default, switch to type aliases for union-heavy schemas where interfaces feel awkward.
Can I name the root type?
Yes — enter a name at the top of the form. Nested types are named automatically (e.g. Root, RootUser, RootUserAddress).
Is my file uploaded anywhere?
No. Everything runs in your browser. Your files never leave your device, and there is no server component for this tool.