JSON to Java POJO

JSON Tools

How to use the JSON to Java POJO

Generate Java POJOs instantly:

1

Paste your JSON

Paste any JSON object into the input panel. Arrays of objects are also accepted — the first element is used for field inference.

2

Set class name

Enter the root class name in PascalCase (e.g. User, Product). Nested objects automatically generate their own named POJO classes.

3

Choose options

Toggle getters/setters, constructors, and @JsonProperty annotations on or off. Options update the output instantly without clicking Generate again.

4

Copy into your IDE

Paste the generated Java classes into your project. All imports are included — java.util.List, java.time.LocalDateTime, and Jackson annotations as needed.


When to use this tool

Use this for Java and Spring Boot development:

  • Building a Spring Boot REST API and need model classes from JSON request/response examples
  • Consuming a REST API with Retrofit in an Android Java project
  • Adding typed models to a Java microservice that processes external JSON data
  • Generating Jackson-compatible DTOs from API documentation JSON samples
  • Scaffolding model classes for a Java project using ObjectMapper to deserialize responses

Frequently asked questions

Q:What Jackson annotations are included?
@JsonProperty annotations are added above every field, matching the original JSON key name exactly. This ensures correct mapping even when your Java field name differs from the JSON key due to camelCase conversion. The required import com.fasterxml.jackson.annotation.JsonProperty is included automatically.
Q:Are getters and setters generated?
Yes — standard getters (getFieldName()) and setters (setFieldName(Type value)) are generated for all fields following Java bean naming conventions. Both can be toggled off from the toolbar if you prefer Lombok or records instead.
Q:Can I use Lombok instead of generated getters and setters?
Yes — turn off the Getters/Setters and Constructor toggles in the toolbar, then add @Data (or @Getter + @Setter + @NoArgsConstructor + @AllArgsConstructor) from Lombok above the class. The @JsonProperty annotations on fields are still compatible with Lombok.
Q:How are nested JSON objects handled?
Nested objects generate separate POJO classes that appear above the root class in the output. The parent class references them by type name. Each nested class has its own imports, getters, setters, and @JsonProperty annotations based on your selected options.
Q:How are JSON arrays mapped to Java types?
JSON arrays become List<T> typed fields. Arrays of strings become List<String>, arrays of numbers become List<Integer> or List<Double>, and arrays of objects generate a named nested POJO class and type the field as List<NestedClass>. The import java.util.List is included automatically when needed.
Q:Does the output work with Spring Boot?
Yes — the generated POJOs are standard Java classes and work directly as Spring Boot @RequestBody parameters, @ResponseBody return types, and JPA entities (with @Entity added manually). For Spring Boot projects using Jackson (the default), deserialization works out of the box with or without @JsonProperty if your field names already match the JSON keys.