export interface User {
id: number,
name: string,
roles: string[],
profile: { "joined": string, "active": boolean }
}export interface User {
id: number,
name: string,
roles: string[],
profile: { "joined": string, "active": boolean }
}Generate TypeScript, Java, C#, Go, Python, Kotlin, Swift or Dart type definitions from a JSON sample. Paste any document and instantly get idiomatic, copy-paste-ready models — computed entirely in your browser.
JSON becomes a typed model through a shared inference step, then that model is rendered per language. This gives you consistent class design everywhere:
{ "id": 42, "roles": ["admin"], "active": true }export interface User {
id: number;
roles: string[];
active: boolean;
}Greenfield integration? Paste one example response and get the data classes you'd otherwise hand-write — then extend them with your domain rules.
Get a typed interface for an endpoint in seconds, or a Zod schema from the sibling JSON-to-Schema tool for runtime validation.
When an API contract changes, diff the old and new sample to see the delta, then regenerate the model to match.
"Inference failed" or "Generation failed"Why: Invalid JSON, or a shape the model cannot represent (for example deeply cyclic or mixed-type arrays).
Fix: Validate the JSON first, and keep arrays homogeneous — a number[] with one string entry confuses every type system.
"expects an object at the root"Why: The top-level JSON is an array, string, number or boolean rather than an object.
Fix: Paste one element of the array instead, or wrap the sample in an object.
All fields non-optionalWhy: A single sample can't prove optionality — inference marks every observed key as required.
Fix: Adjust optional flags by hand, or provide the sibling Schema tool with several samples so it can learn which keys disappear.
The tool infers a type model from your JSON: objects become records/classes, arrays become collections, and values become their nearest scalar type (integer, number, string, boolean, null). It then renders that model in your chosen language — no server involved, so private payloads never leave the browser.
TypeScript interfaces, TypeScript type aliases, Java classes and records, C# classes, Go structs, Python dataclasses, Kotlin data classes, Swift structs, and Dart classes. Pick the generator from the language control above the output.
Scalars map directly, with integer vs number distinguished. Useful string shapes are also recognized: email addresses, UUIDs, dates (YYYY-MM-DD), date-times (ISO-8601) and URLs get format-aware types or validation in the generated schema.
If your JSON is a bare array, string, or number, code generation points that out and asks for an object at the root — most real-world payloads are objects, and giving them a name (the Target type name field) is what makes the generated code useful.
The Target type name field sets the name of the root interface/class/struct (default User). It's applied to both the root type and any nested definition it derives from that name.
It's idiomatic and copy-paste ready, but treat it as a starting skeleton: nullable fields may need Optional/nullable annotations in your stack, and format hints (uuid, email) are validated only where your runtime supports them.
Last reviewed September 2026 · DataFormatter team — this tool processes data locally in your browser.