JSON to Classes (Go, Java, Python)
Turn any JSON payload into typed Go structs, Java classes or records, and Python dataclasses, Pydantic models or TypedDicts.
Paste a JSON object above to get typed classes back instantly.
How it works
Paste a JSON object (or an array of objects) and the tool walks the whole document, infers a
type for every key and turns nested objects into their own named types. Integers become
int / long / int, decimals become float64 /
double / float, arrays become slices, List<…> or
list[…], and keys that are missing from some array elements are marked optional.
Keys that are null everywhere fall back to the language's "any" type, and two
nested objects with the same shape are emitted once and reused.
Choose Go structs with JSON tags or pointer optionals, Java classes with getters and setters
or Java 16+ records, and Python dataclasses, Pydantic models or TypedDicts. Field names are
converted to each language's convention — user_name becomes
UserName in Go, userName in Java and user_name in
Python — and a json tag, @JsonProperty annotation or Pydantic
alias is added whenever the name no longer matches the original key.
Everything runs in your browser with the native JSON parser: your payload is never uploaded, so it is safe to paste API responses, tokens and config files. Use Copy code or Download file to take the result straight into your project.
Frequently asked questions
How do I convert JSON to a class?
Paste a JSON object (or an array of objects) into the box and the classes appear as you type. Pick Go, Java or Python, choose a style — Go structs with JSON tags or pointer optionals, Java classes with getters and setters or Java 16+ records, Python dataclasses, Pydantic models or TypedDicts — then Copy code or Download the file.
How are types and optional fields inferred?
Whole numbers become int/long/int, decimals become float64/double/float, arrays become slices, List<…> or list[…], and nested objects become their own named types. If a key is missing from some elements of an array it is marked optional (json omitempty, a boxed Java type, Optional[...] or NotRequired[...]); keys that are null everywhere fall back to interface{}, Object or Any.
Is it safe to paste sensitive JSON into an online class generator?
With this one, yes: the JSON is parsed and the code generated entirely in your browser with the native JSON parser, so nothing is uploaded to a server. That makes it safe for API responses, access tokens and config files — many other online model generators send your payload to their backend.