JSON to Java POJO Generator
Generate Java classes or records from JSON with Lombok and Jackson options.
Runs entirely in your browser. Your input is never sent to a server.
About the json to java pojo generator
Skip the boilerplate. Paste a sample JSON document and receive ready-to-compile Java: nested classes for objects, typed lists for arrays, and your choice of getters and setters, Lombok annotations or immutable records. Add Jackson annotations to map snake_case fields to camelCase names.
How to use it
- Paste sample JSON and set the root class name and optional package.
- Pick the style (plain POJO, Lombok or record) and Jackson options.
- Copy the generated code or download it as a .java file.
Choosing a style
Three output styles are available. POJO gives private fields with getters and setters. Lombok gives private fields with @Data, @NoArgsConstructor and @AllArgsConstructor, plus an optional @Builder. Record gives a Java record with the fields as components, which needs Java 16 or newer.
All nested objects are generated as static nested classes inside the root class (inside the record for records), so one pasted document produces a single .java file named after your root class. You can also set a package line.
Jackson and field names
JSON keys such as full_name or pin_code are converted to camelCase Java names (fullName, pinCode). With Jackson enabled, @JsonProperty("full_name") is added only where the Java name differs from the key, so the class still maps correctly. A second option adds the annotation to every field, which some teams prefer for consistency. Keys that clash with Java reserved words get an underscore suffix.
Imports for List, JsonProperty and Lombok are added for you, only when they are needed.
How types are inferred
The generator only sees your sample. Whole numbers become int, or long when larger than the int range; decimals become double; true and false become boolean; strings become String. If the same field is a mix of whole numbers and decimals across array items, it widens to double, and truly mixed types fall back to Object. A null or missing value gives Object, and arrays become List of the element type, merging the fields of every element into one class.
Boxed types (Integer, Boolean and so on) are on by default so nulls are safe; turn that off for primitives. Dates arrive as plain strings, so change them to LocalDate or Instant yourself, and review money fields before choosing double over BigDecimal.
Limits and privacy
The JSON root must be an object, or an array of objects. A bare string or number is rejected with an error message. Invalid JSON is reported with line and column. A sample with optional fields in only some records should include them all, otherwise they will be missing from the class.
Generation runs in your browser, nothing is uploaded. Use sample or anonymised data rather than live customer payloads.
Frequently asked questions
How are nested objects and arrays handled?
Each nested object becomes its own static nested class. Arrays become List<T> using the element type found in the sample, merging fields across all elements.
How are types chosen?
Whole numbers become int or long (long when large), decimals become double, true/false become boolean, and null or mixed values become Object. A sample cannot reveal every type, so review the output.
When is @JsonProperty added?
When Jackson is on, it is added to fields whose Java name differs from the JSON key, such as full_name becoming fullName. A second checkbox adds it to every field.
Do records work on every Java version?
No. Records need Java 16 or newer. Choose the POJO or Lombok style for older projects.
Can I generate from a JSON array?
Yes, if it is an array of objects. The fields of all objects are merged into one class.
Related tools
JSON Formatter & Validator
Format, minify, validate and explore JSON with precise error positions.
JSON to CSV Converter
Flatten a JSON array into CSV with custom delimiters and nested-key flattening.
Regex Tester
Test JavaScript regular expressions live with highlighted matches and groups.
JWT Decoder
Decode a JWT header and payload locally. Decoding is not signature verification.