What is JSON to Types?
JSON to Types turns a JSON example — typically an API response — into strongly-typed source code in
the language you're working in: TypeScript interfaces, Go structs with the right
json: tags, Python Pydantic BaseModel classes, Rust
serde-derived structs, or plain Java classes ready for Jackson. It infers the shape
recursively, deduplicates identical sub-objects into shared types, marks fields optional when they're missing from
some array elements, and produces output you can drop straight into your project.
What it generates
- Type-correct primitives — integers, floats, booleans, strings, and
nullmap to each language's idiomatic type (number,int64,i64,Long, etc.). - Optional fields — when an array of objects has the same key sometimes missing, the field is marked optional (
?, pointer in Go,Option<T>in Rust, default-Nonein Pydantic). - Nested types are extracted into named structs/classes and reused if their shape repeats.
- Heterogeneous arrays become union types in TS and string + comment in stricter languages.
- Snake-case ↔ camel-case conversion of field names, with the original name preserved in the JSON tag / alias so on-the-wire data still round-trips.
Why it's better than copy-pasting
Most "JSON to TypeScript" web tools handle one language. Most CLI tools (quicktype, gojson) require an install and a mental tax to remember their flags. This tool runs in the browser, supports five mainstream languages from one input, and lets you tweak the root name, naming convention, and optional-field strategy without leaving the page. Your JSON never leaves your device — paste real production samples without worrying about a third-party server logging them.
Tips
- For arrays, paste an array of representative objects (3–10 items) so the tool can detect optional fields correctly.
- If you see a field typed as
any/interface{}/Box<dyn Any>, the corresponding JSON value was eithernullin every sample or an empty array — provide a non-empty example to narrow it. - Use the Optional dropdown to switch between
foo?: Tandfoo: T | nullstyles depending on your codebase's convention.