JSON to Java
Processed Client SideGenerate Java POJOs from a JSON sample — getters and setters, Lombok, or records, with optional Jackson annotations.
Bookmark this tool now — skip the search next time you need it.
About JSON to Java
This tool runs entirely in your browser. Whatever you paste is processed on your own device and is never uploaded, logged, or sent to any server.
The JSON to Java converter turns a sample JSON payload into Java classes you can deserialize straight into with Jackson or Gson. Nested objects become their own types, emitted as static nested classes so the entire model stays in a single .java file that compiles as-is. Arrays become List<T>, and numbers are mapped to int, long, or double from the values actually present. Keys become camelCase fields with @JsonProperty where the Java name differs from the wire name, and you can generate plain POJOs with getters, Lombok-annotated classes, or Java records depending on what your codebase uses.
Key features
- Three output styles: POJOs with getters and setters, Lombok-annotated classes, or Java records
- Optional @JsonProperty annotations, emitted only where the Java field name differs from the JSON key
- Optional package declaration, with imports added only when the model actually needs them
- Nested objects emitted as static nested classes, so the whole model is one compilable file
- Arrays of objects merged into a single type, with fields missing from some elements marked nullable
- Boxed wrapper types (Integer, Boolean, Double) used for nullable fields and inside generics, primitives everywhere else
- Numeric types inferred from the data — int, long past Int32 range, double for any fractional value
- Java reserved words handled: a field that would be called class or public gets a trailing underscore instead of failing to compile
- Syntax-highlighted Java output and one-click copy, generated entirely in your browser
How to use it
- Paste a representative JSON response into the input pane.
- Set the root class name, and a package such as com.example.model if you want the declaration emitted.
- Pick the style — getters, Lombok, or record — and switch Jackson annotations on or off.
- Press Convert and read the generated classes.
- Copy the file into your project and deserialize with objectMapper.readValue(json, Root.class).
Tips & common mistakes
- Paste the fullest sample you can find. Fields that are null in your only sample come out as Object, and empty arrays come out as List<Object>.
- Nullable fields deliberately use Integer rather than int. A primitive cannot hold null, so an absent number would silently deserialize as 0 and hide a missing value.
- Records are immutable and need Jackson 2.12 or later to deserialize without extra configuration. If you are on an older version, or a framework needs a no-args constructor, choose getters instead.
- Lombok keeps the file short but requires the dependency and IDE plugin. Plain getters are the safer default for code that will be read more often than it is written.
- Keep @JsonProperty on unless you have configured a global naming strategy. Without either, a snake_case key will not bind to a camelCase field and you will get a null with no error.
- A key that appears with different types across samples becomes Object, because no single static type covers both. Fixing that on the API side is usually better than working around it in the model.
- Working in C# instead? The JSON to C# converter runs the same analysis and emits classes or records with System.Text.Json or Newtonsoft attributes.