JSON to Java クラス
JSON を Java POJO クラス(getter/setter 付き)または Lombok @Data アノテーションクラスに変換します。
What Is the JSON to Java Class Generator?
The JSON to Java class generator converts a JSON object into Java class definitions. Paste any JSON and the tool produces either a plain POJO with getters and setters, or a Lombok-annotated class using @Data, @NoArgsConstructor, and @AllArgsConstructor. Nested objects are automatically extracted into separate classes, and arrays are typed as List<T>.
This tool is useful when building Java REST clients, mapping API responses to model classes, or scaffolding data transfer objects (DTOs) from a JSON schema. It handles the tedious field declaration and boilerplate generation so you can focus on business logic.
How to Use the JSON to Java Generator
- Paste your JSON object into the left panel, or click Load Sample.
- Choose POJO for plain Java with getters/setters, or Lombok @Data for annotation-based boilerplate reduction.
- Set the root class name (defaults to Root).
- The generated Java classes appear on the right. Click Copy to copy all classes.
Features
- Generates POJO classes with private fields and public getters/setters
- Generates Lombok @Data classes with @NoArgsConstructor and @AllArgsConstructor
- Handles nested objects — each becomes a separate named class
- Maps JSON arrays to List<T> with inferred element type
- Type mapping: string → String, boolean → boolean, integer → int, decimal → double, null → Object
- Field names automatically converted to camelCase
- Class names automatically converted to PascalCase
- Configurable root class name
FAQ
What is a POJO in Java?
POJO stands for Plain Old Java Object. It is a simple Java class with private fields and public getter and setter methods, with no dependency on any framework. POJOs are commonly used to represent data models, API response objects, and database entities.
What is Lombok @Data?
Lombok is a Java library that reduces boilerplate code. The @Data annotation automatically generates getters, setters, equals(), hashCode(), and toString() methods at compile time. Combined with @NoArgsConstructor and @AllArgsConstructor, it replaces hundreds of lines of repetitive code.
How are JSON types mapped to Java types?
JSON strings map to String, JSON booleans to boolean, JSON integers to int, JSON decimals to double, JSON arrays to List<T>, JSON objects to a nested class, and JSON null to Object.
How are nested JSON objects handled?
Each nested JSON object generates a separate Java class. The class name is derived from the JSON key using PascalCase. For example, a key "address" containing an object generates an Address class, and the parent class has a field of type Address.