JSON to Java class
Paste a JSON sample to get Java classes: POJOs with getters and setters or records (Java 16+), boxed types for nulls and optional Jackson annotations.
How to generate Java classes from JSON
- Paste a JSON sample on the left or open a .json file; the Java code appears on the right.
- Choose a class (getters/setters) or a record, and turn on Jackson if your project uses it.
- Copy it or download the .java file — named after the root class, as Java requires.
Frequently asked questions
A record (Java 16 and later) is much shorter and cannot change once made, which suits data read from an API. Pick a class for older Java or when values need setters.
int, double and boolean cannot hold null. Fields that are sometimes null or missing use the boxed Integer, Double and Boolean. Very large integers (such as 19-digit IDs) use long or Long.
Java uses camelCase, so first_name becomes firstName. With Jackson on, @JsonProperty("first_name") is added so Jackson still reads the original JSON. With it off, the original name is noted at the end of the line.
A Java file holds one public class, so the other classes are nested (static) inside it — paste it once and it compiles.
It is completely free and needs no sign-up.
Related tools
JSON to TypeScriptGenerate TypeScript interfaces from sample JSONJSON to Go structGenerate Go structs from a JSON sampleJSON to Kotlin data classGenerate Kotlin data classes from a JSON sampleJSON Escape / UnescapeTurn text into a valid JSON string and backJSON FormatterFormat, minify and validate JSONJSON RepairAutomatically fix broken JSONJSON CompareFind the differences between two JSON documentsJSON ViewerView JSON as a tree, collapse or expand any branchJSON SorterSort JSON fields and arrays from A to Z