JSON to Java Class (POJO) Generator — Free Online Tool
Convert JSON to Java POJO class definitions with proper types, getters, setters, and Jackson annotations using AI. Free, no sign-up.
JSON to Java Class (POJO) Generator — Free Online Tool
About JSON to Java Class (POJO) Generator — Free Online Tool
JSON to Java POJO converts a JSON object or array into a ready-to-use Java class with Jackson annotations (@JsonProperty, @JsonIgnoreProperties), private fields, and public getters and setters. Developers use it to eliminate manual boilerplate when integrating REST APIs, deserializing payloads, or mapping database responses into typed domain objects.
JSON to Java Type Mapping
| JSON Type | Java Type | Notes |
|---|---|---|
| string | String | Always mapped to java.lang.String |
| number (integer) | int / Integer | Use Integer when field may be null |
| number (decimal) | double / Double | Use Double for nullable decimal fields |
| boolean | boolean / Boolean | Use Boolean when field may be absent |
| null | Object / Optional<T> | Jackson maps null to null; use Optional for explicit absence |
| array | List<T> | Requires generic type; imported from java.util.List |
| object | Nested POJO class | Each nested object becomes its own class definition |
| date string (ISO 8601) | String / LocalDateTime | Add @JsonFormat for automatic date parsing |
JSON-to-Java Tool: Format and Annotation Comparison
| Feature | Jackson (default) | Gson | Moshi | Jakarta EE (JSON-B) |
|---|---|---|---|---|
| Annotation style | @JsonProperty | Field name conventions / @SerializedName | @Json | @JsonbProperty |
| Null handling | @JsonInclude(NON_NULL) | serializeNulls() | Skipped by default | @JsonbNillable |
| Date parsing | @JsonFormat pattern | GsonBuilder.setDateFormat() | @JsonAdapter | @JsonbDateFormat |
| Unknown fields | @JsonIgnoreProperties(ignoreUnknown=true) | Lenient by default | Fails on unknown keys by default | @JsonbTransient |
| Immutable objects | @JsonCreator + @JsonProperty | Custom TypeAdapter | Value classes / @Json | @JsonbCreator |
| Spring Boot default | Yes | Optional, must exclude Jackson | No | No |
Frequently Asked Questions
How do I convert JSON to a Java class with Jackson annotations?
Paste your JSON into the tool and it generates a Java POJO with @JsonProperty on each field, private field declarations, and public getters and setters. The class also includes @JsonIgnoreProperties(ignoreUnknown = true) at the top level so your code does not break when the API adds new fields. Copy the output directly into your src/main/java directory.
What Jackson dependency do I need to deserialize JSON to a Java object?
Add com.fasterxml.jackson.core:jackson-databind to your pom.xml or build.gradle. For Spring Boot projects this dependency is already included transitively via spring-boot-starter-web. To deserialize, call new ObjectMapper().readValue(jsonString, YourClass.class).
How does the tool handle nested JSON objects and arrays?
Each nested JSON object becomes a separate inner or top-level POJO class, and JSON arrays become List<T> fields with the correct generic type. For example, a field 'orders': [{...}] generates a List<Orders> field alongside an Orders class. You can then navigate the full object graph using standard Java dot notation.
Why use @JsonProperty instead of matching field names to JSON keys?
@JsonProperty lets you follow Java naming conventions (camelCase) while the JSON payload uses snake_case, kebab-case, or any other naming style. For example, @JsonProperty("first_name") private String firstName; maps the JSON key first_name to the Java field firstName without any ObjectMapper configuration. This keeps your Java code idiomatic while remaining compatible with the exact wire format.
How do I handle nullable fields in a Java POJO generated from JSON?
Use boxed types (Integer, Double, Boolean) instead of primitives (int, double, boolean) for any field that may be null or absent in the JSON. Add @JsonInclude(JsonInclude.Include.NON_NULL) at the class level to skip null fields during serialization. For optional fields, Jackson simply leaves them at their default Java value (null for objects, 0 for primitives) when the key is missing from the input JSON.
If jsondecode.com saved you time, share it with your team
Free forever. No ads. No sign-up. Help other developers find it.