Convert any JSON into Java POJO classes instantly. Get fully structured Java classes with private fields, public getters, setters, and optional Jackson or Gson annotations - free, no account needed.
A POJO (Plain Old Java Object) is the backbone of data modeling in Java. When you receive JSON from a REST API, a database, or a configuration file, you need a Java class that mirrors that JSON structure so your application can work with it in a type-safe way. Writing these classes by hand is tedious and error-prone, especially for large or deeply nested JSON payloads.
A typical POJO follows a strict convention: private fields that match the JSON keys, a no-argument constructor, and public getter and setter methods for each field. For example, the JSON {"userId": 42, "name": "Alice"} maps to a Java class with private int userId and private String name, along with their corresponding getUserId(), setUserId(), getName(), and setName() methods.
POJOs are used across the entire Java ecosystem: Spring Boot REST controllers, Android network layers, Hibernate entity models, and standalone data processing utilities all rely on POJOs to represent structured data. Automating their creation saves hours of boilerplate work and eliminates typos in field names.
Our converter parses your JSON and generates Java source code following standard conventions. Here is how to use it:
The tool infers Java types from JSON value types: JSON strings become String, JSON numbers with decimals become Double, whole numbers become Integer or Long, JSON booleans become Boolean, JSON arrays become List<T>, and nested JSON objects become separate inner classes.
Two libraries dominate JSON processing in Java: Jackson and Gson. Understanding which annotations to use depends on which library your project includes.
Jackson is the default in Spring Boot and is the most widely used Java JSON library. Key annotations include:
@JsonProperty("field_name") - Maps a JSON key to a Java field with a different name@JsonIgnoreProperties(ignoreUnknown = true) - Silently ignores extra JSON fields not in the class@JsonInclude(JsonInclude.Include.NON_NULL) - Skips null fields during serializationGson is popular in Android development and standalone Java projects. Its primary annotation is:
@SerializedName("field_name") - Maps a JSON key to a Java field nameLombok is not a JSON library but a code generation tool. Adding @Data to your POJO class automatically generates all getters, setters, equals(), hashCode(), and toString() at compile time, dramatically reducing boilerplate.
Generating Java classes from JSON is a daily task for many backend and Android developers. Here are the most common scenarios where this tool saves significant time:
A POJO (Plain Old Java Object) is a Java class with no special requirements - no mandatory superclasses, no required interfaces, and no required annotations. It simply has private fields and public getters/setters. The term distinguishes it from objects that require a specific framework, like EJBs (Enterprise JavaBeans). In the context of JSON, POJOs are the standard way to represent JSON data as a Java object that Jackson or Gson can serialize and deserialize.
If you use Spring Boot or any Jackson-based project, add @JsonProperty on fields whose JSON key differs from the Java field name, and @JsonIgnoreProperties(ignoreUnknown = true) at the class level to tolerate extra fields. For Android with Retrofit and Gson, use @SerializedName. If your team uses Lombok, replace all getters and setters with @Data on the class to keep the code minimal.
Each nested JSON object becomes a separate Java class. For example, if your JSON has an "address" field that contains an object with "street", "city", and "zip", the generator creates an Address class with those three fields, and the parent class gets a field private Address address. Deeply nested structures are handled recursively, producing a clean class hierarchy.
JSON arrays are mapped to List<T> where T is the inferred element type. An array of strings becomes List<String>, an array of numbers becomes List<Integer> or List<Double>, and an array of objects becomes List<YourClassName> where the element class is also generated. The import for java.util.List is automatically included in the output.
Free, instant, 100% private. No account needed.
Java POJOs (Plain Old Java Objects) are the standard way to deserialize JSON in Java. Jackson and Gson are the two most popular libraries, each with slightly different annotations.
// JSON
{"userId": 1, "name": "Alice", "active": true, "score": 98.5}
// Java (Jackson)
import com.fasterxml.jackson.annotation.JsonProperty;
public class User {
@JsonProperty("userId")
private int userId;
@JsonProperty("name")
private String name;
@JsonProperty("active")
private boolean active;
@JsonProperty("score")
private double score;
// Getters and setters
public int getUserId() { return userId; }
public void setUserId(int userId) { this.userId = userId; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
}
| Library | Annotation | Deserialize Method | Notes |
|---|---|---|---|
| Jackson | @JsonProperty | ObjectMapper | Most popular, Spring default |
| Gson | @SerializedName | Gson().fromJson() | Google library, simpler API |
| Moshi | @Json | Moshi adapter | Kotlin-friendly, modern |
| JSON-B (Jakarta) | @JsonbProperty | Jsonb.fromJson() | Java EE standard |
// Jackson
ObjectMapper mapper = new ObjectMapper();
User user = mapper.readValue(jsonString, User.class);
// Jackson from file
User user = mapper.readValue(new File("user.json"), User.class);
// Gson
Gson gson = new Gson();
User user = gson.fromJson(jsonString, User.class);
// List of objects
List<User> users = mapper.readValue(jsonArray,
mapper.getTypeFactory().constructCollectionType(List.class, User.class));
Also useful: JWT Decoder | JSON Validator | JSON Formatter | JSON to Go | JSON to C# | JSON to Kotlin
// Generated POJO from {"name": "Alice", "age": 30, "email": "alice@example.com"}
public class User {
@JsonProperty("name")
private String name;
@JsonProperty("age")
private int age;
@JsonProperty("email")
private String email;
// Getters and setters omitted for brevity
}
// Deserialization with Jackson
ObjectMapper mapper = new ObjectMapper();
User user = mapper.readValue(jsonString, User.class);
System.out.println(user.getName()); // "Alice"
// Deserialization with Gson
Gson gson = new Gson();
User user = gson.fromJson(jsonString, User.class);
| Feature | Jackson | Gson |
|---|---|---|
| Maintained by | FasterXML | |
| Spring Boot default | Yes | No |
| Annotation style | @JsonProperty, @JsonIgnore | @SerializedName, @Expose |
| Streaming API | Yes (JsonParser) | Yes (JsonReader) |
| Performance | Faster for large objects | Faster for small objects |
| Configuration | ObjectMapper (reusable) | GsonBuilder |
| Best for | Spring projects, enterprise | Android, simple projects |
| JSON Type | Java Type | Notes |
|---|---|---|
| String | String | Standard Java string |
| Integer | int / Integer | Use Integer for nullable fields |
| Float/Double | double / Double | Use Double for nullable |
| Boolean | boolean / Boolean | Use Boolean for nullable |
| null | null | Object types only, not primitives |
| Array | List<T> / T[] | T is the element type |
| Object | Custom class | Each object becomes a Java class |
Several tools generate Java classes from JSON. Here is how this tool compares to the most common alternatives developers use:
| Tool | Free | Annotations | Nested Objects | No Signup |
|---|---|---|---|---|
| JSON Web Tools | ✓ | Jackson & Gson | ✓ | ✓ |
| json2csharp.com | ✓ | C# only | ✓ | ✓ |
| jsonschema2pojo.org | ✓ | Jackson, Gson, JSR | ✓ | ✓ |
| IntelliJ IDEA plugin | Paid IDE | ✓ | ✓ | Requires IDE |
Converting JSON to a Java POJO (Plain Old Java Object) online takes under 30 seconds:
@JsonProperty), or Gson (@SerializedName)User, Product)Input JSON:
{
"userId": 101,
"name": "Alice Smith",
"email": "alice@example.com",
"active": true,
"address": {
"street": "123 Main St",
"city": "New York",
"zip": "10001"
},
"tags": ["admin", "editor"]
}
Generated Java POJO (with Jackson annotations):
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
public class User {
@JsonProperty("userId")
private int userId;
@JsonProperty("name")
private String name;
@JsonProperty("email")
private String email;
@JsonProperty("active")
private boolean active;
@JsonProperty("address")
private Address address;
@JsonProperty("tags")
private List<String> tags;
// Getters and setters...
public static class Address {
@JsonProperty("street")
private String street;
@JsonProperty("city")
private String city;
@JsonProperty("zip")
private String zip;
// Getters and setters...
}
}
Also useful: JSON to TypeScript | JSON to Go struct | JSON to C# | JSON to Python dataclass | JSON Schema Validator