JSON to Java
Generate Java POJOs from JSON. Supports Jackson annotations, Lombok @Data, and Java 16+ Records. Free online Java class generator.
Generate Java POJOs, Lombok data classes, or Java 16+ Records from any JSON structure. The tool maps JSON types to correct Java types, generates proper camelCase field names, and optionally adds Jackson or Gson annotations — ready to paste directly into your Maven or Gradle project.
Related tools
Frequently asked questions
What is a Java POJO?
POJO (Plain Old Java Object) is a simple Java class with private fields and public getters/setters. It has no dependency on any framework. POJOs are the standard pattern for representing JSON data structures in Java — used with Jackson, Gson, Spring Boot, and Android development.
What is Lombok @Data and do I need it?
Lombok is a Java library that generates boilerplate at compile time via annotations. @Data generates getters, setters,
equals(),
hashCode(), and
toString(). It's widely used in Spring Boot projects. Add
org.projectlombok:lombok to your build file to use it.
What is a Java Record and when should I use it?
Java Records (Java 16+) are immutable data classes. The compiler auto-generates a
constructor, getters (without get prefix), equals(),
hashCode(), and
toString(). Use records for immutable value objects like API response DTOs. Jackson supports records
natively in Jackson 2.12+.
When should I use Jackson vs Gson?
Jackson is the default in Spring Boot and is generally faster and more feature-rich. Gson is Google's library — simpler API, popular in Android development. Both can deserialize JSON into Java classes. Choose based on your existing dependencies: Spring Boot includes Jackson automatically.
How are Java types mapped from JSON values?
JSON strings → String. JSON integers → int. JSON decimals → double. JSON booleans → boolean. JSON null → Object. JSON arrays of objects → List<ClassName>. Nested objects become separate class definitions.
How do I deserialize JSON into the generated Java class?
With Jackson:
Root obj = new ObjectMapper().readValue(jsonString, Root.class);. With Gson:
Root obj = new Gson().fromJson(jsonString, Root.class);. Make sure the class is on the classpath and all nested classes are in the same file or
properly imported.