JSON to Java POJO
Convert JSON to Java classes, with optional Lombok annotations
What is JSON to Java POJO?
This JSON to Java converter generates POJO definitions from sample data and annotates each field with @JsonProperty so the original key name survives. You can either lean on the Lombok @Data annotation or generate full getters and setters. The inference runs entirely in your browser.
How to use JSON to Java POJO
- 1Paste a sample JSON response.
- 2Enter the root class name. Nested objects become classes of their own.
- 3Decide whether to use Lombok based on your project conventions.
- 4After copying, split the output into separate files, since Java requires a public class to match its file name.
Frequently asked questions
Why use the wrapper type Long instead of the primitive long?+
A JSON field may be absent or null, and a primitive has no way to represent the absence of a value, so deserialization quietly fills in 0 and changes the meaning of your data. Wrapper types preserve null, at the cost of null checks in your business logic.
What still needs adjusting in the generated classes?+
Three things. Split each class into its own file and add the package declaration, add validation annotations to optional fields based on your API contract, and check whether any field type should be narrowed. Monetary amounts, for example, belong in BigDecimal rather than Double.
Related tools
All toolsJSON to YAML Converter
Convert JSON to YAML while preserving the nesting
YAML to JSON Converter
Convert YAML to JSON, multi-document files included
JSON to CSV Converter
Convert a JSON array of objects to CSV, with nested fields flattened automatically
CSV to JSON Converter
Convert CSV to JSON with automatic header and delimiter handling
JSON to TypeScript
Infer TypeScript type definitions from JSON
JSON to Go Struct
Convert JSON to Go structs with json tags filled in