JSON to Java Class (POJO) Generator
Generate Java POJO classes from JSON with getters, setters and optional Jackson @JsonProperty annotations.
Types are inferred from the sample. Fields missing in some array items become optional; null values become nullable.
Model classes for Java projects
Writing POJOs for API responses in Spring Boot apps, Android projects or microservices is repetitive. The JSON to Java generator creates these classes automatically.
The right types
- Primitive types such as int, double and boolean for fields that always have a value
- Boxed types such as Integer, Double and Boolean for fields that can be missing or null
- List<T> for arrays
- Separate classes for nested objects
Jackson support
Optionally add @JsonProperty annotations to keep the mapping between Java-style field names and JSON keys. Code is generated in your browser.
How to use JSON to Java Class (POJO) Generator
- Paste sample JSON data.
- Set the class name and Jackson preference.
- Review the generated Java code.
- Copy the classes into your project.
Why use this tool?
Cuts boilerplate writing time and reduces null-related bugs through the right type choices.
FAQ
Why is a field Integer instead of int?
Because it's null or missing in some samples; int can't hold null.
Can I use Lombok?
Delete the generated getters and setters and add @Data to the class to use Lombok.
Can it generate Java records?
The tool generates classic POJO classes.
Related tools
JSON to C# Class Generator
Generate C# classes or records from JSON with nested types, List<T>, nullable types and [JsonPropertyName].
Open toolJSON to Dart Model Generator
Generate null-safe Dart/Flutter model classes with fromJson and toJson from JSON.
Open toolJSON to Python Dataclass Generator
Generate typed Python dataclasses from JSON with Optional fields and a from_dict() helper.
Open toolJSON Formatter and Validator
Pretty-print messy or minified JSON and find errors with line and column details.
Open tool