JSON to Java POJO Generator β€” Convert JSON to Java Classes Online Free

Generate Java POJO classes from JSON

JSON Input
Java Output

Code Style Reference

  • Lombok @Data β€” Adds @Data which auto-generates getters, setters, equals, hashCode, and toString at compile time. Requires the Lombok dependency. The cleanest option for Spring Boot projects.
  • Getter + Setter β€” Plain POJO with explicit getXxx() and setXxx() methods. No extra dependencies. Verbose but universally compatible.
  • Java Record β€” Immutable value class using the record keyword (Java 16+). Auto-generates a canonical constructor, accessors, equals, hashCode, and toString. Ideal for DTOs and read-only response models.

Annotation Libraries

  • Jackson β€” The default JSON library in Spring Boot. @JsonProperty("field_name") maps a snake_case JSON key to a camelCase Java field. @JsonIgnoreProperties(ignoreUnknown = true) on the class prevents errors when the API adds new fields.
  • Gson β€” Google's JSON library. Uses @SerializedName("field_name") for field mapping. Common in Android and non-Spring Java projects.

Frequently Asked Questions

How are JSON types mapped to Java types?

string β†’ String, number (integer) β†’ Integer, number (decimal) β†’ Double, boolean β†’ Boolean, null β†’ Object, array β†’ List<T>, object β†’ nested class. Wrapper types (Integer vs int) are used throughout so fields can represent null values from JSON.

When should I use Java Records vs Lombok?

Use Records for immutable DTOs β€” API response models you only read, never mutate. Use Lombok @Data for entities and models that need setters (e.g., JPA entities, request bodies that frameworks populate by reflection). Records require Java 16+; Lombok works from Java 8.

How do I handle snake_case JSON keys in Spring Boot?

Either add @JsonProperty("snake_key") per field (generated by this tool when enabled), or configure Jackson globally: spring.jackson.property-naming-strategy=SNAKE_CASE in application.properties. The global approach is cleaner when all your API keys follow snake_case consistently.