How is JSON converted to a TypeScript interface?
The converter inspects sample values to infer TypeScript property types, then creates an interface for the root object and additional interfaces for nested objects.
Paste sample JSON and generate TypeScript models locally in your browser.
Use an object or an array of objects for model inference.
Generated code will appear here.Turn a representative JSON object or an array of objects into TypeScript declarations without sending the sample to a server. The converter infers primitive values, arrays, nested objects, and fields that are missing from some array items.
Choose interfaces for declarations that can be extended or type aliases for a compact object type. The same inferred model powers both styles, so changing the output style does not change the detected fields.
Nested JSON objects become named TypeScript declarations instead of loose object values. Property names can be normalized to camelCase, and exported or readonly declarations can be generated when those constraints fit the project.
Optional properties represent fields missing from some object samples. Nullable properties preserve observed null values with a union when nullable output is enabled; the two concepts remain separate.
Example JSON input:
{
"account_id": 7,
"profile": {
"display_name": "Ada"
},
"roles": ["admin", "editor"]
}Generated TypeScript output:
export interface RootModel {
accountId: number;
profile: RootModelProfile;
roles: string[];
}
export interface RootModelProfile {
displayName: string;
}The converter inspects sample values to infer TypeScript property types, then creates an interface for the root object and additional interfaces for nested objects.
Both outputs describe the same inferred object shape. Interfaces use interface declarations and are designed for extension and declaration merging, while type aliases use object type syntax and can fit codebases that standardize on type.
When a field is null in one of the samples, nullable output can add a null union to its inferred non-null type. Missing fields are tracked separately as optional properties.
Each nested object receives a stable name based on its parent model and JSON key. The parent property then references that generated declaration.
No. Parsing, inference, generation, copying, and downloading all happen in the browser. Input and generated TypeScript are not stored between sessions.
Your JSON input, field names, root model name, and generated TypeScript source stay in this browser. They are not sent to a backend, added to the URL, or saved in local storage or cookies.
Compare another language-specific converter that uses the same local JSON inference engine.