JSON to POJO Java Generator — Free Online Tool
Convert JSON to Java POJO class definitions with Jackson annotations, private fields, getters, and setters using AI.
JSON to POJO Java Generator — Free Online Tool
What is a Java POJO?
A POJO (Plain Old Java Object) is a simple Java class that holds data — private fields, public getters and setters, and no special framework dependencies. When working with JSON APIs in Java, you deserialize JSON into a POJO so your code can access fields as typed properties instead of raw strings.
This tool takes any JSON object and generates the corresponding Java POJO class with correct Java types, @JsonProperty annotations for Jackson, and @JsonIgnoreProperties(ignoreUnknown = true) for safe deserialization.
Jackson vs Gson — POJO Annotation Comparison
| Feature | Jackson | Gson |
|---|---|---|
| Field mapping | @JsonProperty("key") | @SerializedName("key") |
| Ignore unknown fields | @JsonIgnoreProperties(ignoreUnknown = true) | No annotation needed |
| Deserialize | objectMapper.readValue(json, T.class) | gson.fromJson(json, T.class) |
| Serialize | objectMapper.writeValueAsString(obj) | gson.toJson(obj) |
| Maven artifact | jackson-databind | gson |
| Spring Boot default | Yes — auto-configured | No — manual bean |
JSON to Java Type Mapping
| JSON type | Java type | Notes |
|---|---|---|
| string | String | |
| integer | Integer / Long | Use Long for values > 2³¹ |
| float / decimal | Double / BigDecimal | Use BigDecimal for currency |
| boolean | Boolean | |
| null | Optional<T> or T (nullable) | Annotate with @JsonInclude |
| array | List<T> | T is the element type |
| object | Nested POJO class | Generate a separate class |
Frequently Asked Questions
What is a POJO in Java?
A POJO (Plain Old Java Object) is a simple Java class with private fields and public getter/setter methods. It does not extend any framework class or implement any special interface. POJOs are the standard way to model JSON API responses in Java.
How do I deserialize JSON to a POJO in Java?
With Jackson: ObjectMapper mapper = new ObjectMapper(); MyClass obj = mapper.readValue(jsonString, MyClass.class); — the POJO fields must match the JSON keys, or use @JsonProperty to map different names.
What Maven dependency do I need for Jackson?
Add com.fasterxml.jackson.core:jackson-databind to your pom.xml. If you're using Spring Boot, it's already included transitively via spring-boot-starter-web.
Should I generate getters and setters?
Yes, Jackson requires either public fields or getter/setter pairs for serialization and deserialization. This tool generates private fields with getters and setters by default.
How do I handle nested JSON objects?
Each nested JSON object becomes a separate POJO class. The parent class holds a field of the nested class type. This tool generates all required nested classes from the JSON structure.
What does @JsonIgnoreProperties(ignoreUnknown = true) do?
It tells Jackson to silently ignore any JSON fields that don't have a matching field in the POJO. Without it, Jackson throws an UnrecognizedPropertyException when the API adds new fields — which is a common cause of deserialization failures in production.
If jsondecode.com saved you time, share it with your team
Free forever. No ads. No sign-up. Help other developers find it.