JSON to Java Classes Converter

Paste JSON to generate Java POJOs, Lombok classes, or Java Records. 100% client-side.

JSON Input
Java Output
Paste JSON above to generate Java classes.

How to Convert JSON to Java Classes

  1. Paste your JSON into the input area on the left.
  2. Choose a mode — POJO (classic getters/setters), Lombok (annotation-driven), or Record (Java 16+ immutable).
  3. Copy or download the generated Java code using the buttons above the output.
  4. Add it to your project and use with Jackson or Gson to deserialize JSON at runtime.

Java JSON Libraries Overview

Java's most popular JSON libraries are Jackson and Gson. Jackson (com.fasterxml.jackson.core:jackson-databind) is the de facto standard, used by Spring Boot, Quarkus, and Micronaut. Gson (com.google.code.gson:gson) is Google's library, popular in Android development. Both work with the generated POJOs from this tool without additional configuration, assuming your JSON uses camelCase keys matching the Java getter/setter convention.

Output Modes Explained

  • POJO — Classic Java class with private fields, public getters (getName()), and public setters (setName(String name)). The JavaBeans standard. Compatible with all Java JSON libraries, XML frameworks, and Java EE/Jakarta EE. Best for maximum compatibility and projects without build-time annotation processing.
  • Lombok — Adds @Data (generates getters, setters, equals, hashCode, toString), @NoArgsConstructor, and @AllArgsConstructor. Also adds @JsonDeserialize for Jackson compatibility. Requires Lombok on the classpath and IDE plugin installation. Dramatically reduces boilerplate — a 50-line POJO becomes 10 lines.
  • Record — Java 16+ record syntax. Records are immutable: fields are set at construction and cannot be changed. Accessor methods are generated automatically (no "get" prefix: name() not getName()). Jackson 2.12+ and Gson 2.10+ support records. Ideal for read-only API response models.

Java Type Mapping from JSON

  • JSON string → String
  • JSON integer → int (primitive) or Integer (nullable)
  • JSON float → double (primitive) or Double (nullable)
  • JSON boolean → boolean (primitive) or Boolean (nullable)
  • JSON null → Object (use wrapper types for nullable primitives)
  • JSON array of strings → List<String>
  • JSON array of objects → List<ChildClass>
  • JSON nested object → separate class definition

Using Generated Classes with Jackson

Add Jackson to your Maven project: <dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId></dependency>. Then deserialize: ObjectMapper mapper = new ObjectMapper(); RootObject obj = mapper.readValue(jsonString, RootObject.class);. For arrays: List<RootObject> list = mapper.readValue(jsonString, new TypeReference<List<RootObject>>(){});. Spring Boot auto-configures an ObjectMapper bean — just use @RequestBody RootObject data in your controller.

Setting Up Lombok

Lombok requires annotation processing in your IDE and a build dependency. For Maven: add org.projectlombok:lombok with provided scope. For Gradle: use compileOnly 'org.projectlombok:lombok' and annotationProcessor 'org.projectlombok:lombok'. In IntelliJ IDEA: install the "Lombok" plugin from the marketplace. In Eclipse: run the Lombok installer jar. Once set up, the @Data annotation replaces all getter, setter, equals, and hashCode code with a single annotation.

Java Records and Immutability

Java Records guarantee immutability — once constructed, a record's fields cannot be changed. This makes records ideal for representing API responses that should not be mutated. The compact record syntax public record Person(String name, int age) is equivalent to a full class with a constructor, two final fields, two accessor methods, and implementations of equals, hashCode, and toString. Jackson supports records via the jackson-module-parameter-names module which reads constructor parameter names. Spring Boot 2.7+ includes this module automatically.

JSON to Java vs. Other Languages

Java's approach to JSON is more verbose than dynamic languages due to its static type system, but this verbosity provides compile-time safety and IDE support. Compared to Go's struct tags, Java requires no annotations by default when using camelCase — Jackson's default naming strategy matches JSON camelCase to Java camelCase fields. Compared to Python, Java requires more lines but gets type safety and IntelliSense in return. For a typed alternative with less boilerplate, see our JSON to Kotlin converter or the JSON to TypeScript converter for frontend work.

Frequently Asked Questions

POJO stands for Plain Old Java Object — a simple Java class with private fields, public getters, and public setters. POJOs do not extend framework classes or implement framework interfaces, making them portable and testable. JSON libraries like Jackson and Gson use Java POJOs to map JSON properties to Java fields via the standard JavaBeans convention.
Lombok is a Java annotation processing library that generates boilerplate code at compile time. The @Data annotation generates getters, setters, equals(), hashCode(), and toString() for all fields. This eliminates hundreds of lines of repetitive code. To use Lombok, add it to your build tool (Maven: lombok dependency, Gradle: compileOnly 'org.projectlombok:lombok') and install the IDE plugin.
Java Records (introduced in Java 16, finalized in Java 17) are immutable data classes with automatic equals(), hashCode(), toString(), and accessor methods. They are ideal for data transfer objects (DTOs) that represent values received from an API. Jackson supports Java Records for JSON deserialization since Jackson 2.12. Use Records when your data should not be mutated after creation.
Add Jackson to your project (com.fasterxml.jackson.core:jackson-databind). Then: ObjectMapper mapper = new ObjectMapper(); RootObject obj = mapper.readValue(jsonString, RootObject.class). Jackson uses the getter and setter names to map JSON properties to Java fields by default. No additional annotations are needed for standard camelCase JSON.
No. This converter runs entirely in your browser using JavaScript. Your JSON never leaves your device. There is no backend, no logging, and no data collection of any kind.