$ Convert JSON to Java classes
Paste JSON and generate Java POJO classes with typed fields, getters and setters — or Java interfaces.
JSON Input
Paste a JSON payload and generate typed definitions.
Generated Output
Classes ready to copy.
public class Profile {
private String displayName;
private String signupAt;
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getSignupAt() {
return signupAt;
}
public void setSignupAt(String signupAt) {
this.signupAt = signupAt;
}
}
public class RootPayload {
private Integer id;
private String email;
private Boolean isActive;
private List<String> roles;
private Profile profile;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Boolean getIsActive() {
return isActive;
}
public void setIsActive(Boolean isActive) {
this.isActive = isActive;
}
public List<String> getRoles() {
return roles;
}
public void setRoles(List<String> roles) {
this.roles = roles;
}
public Profile getProfile() {
return profile;
}
public void setProfile(Profile profile) {
this.profile = profile;
}
}Why use an online JSON to Java class converter
Mapping a JSON response to Java means writing a class with a private field, a getter and a setter for every key — and repeating it for each nested object. It is pure boilerplate, and a single typo breaks deserialization.
This JSON to Java class converter generates those POJOs from a sample payload. Field names match the JSON keys and every field has a getter and setter, which is exactly the convention Jackson (ObjectMapper) and Gson use by default.
Switch the target to Java Interface if you only need getter signatures. Everything runs in your browser, so you can paste real API responses safely.
JSON to Java class converter use cases
JSON to Java class converter examples: input and output
POJO with getters and setters
Arrays become List<T>, nested objects become classes
Common JSON to Java class converter errors and how to fix them
cause:Jackson found a JSON key that has no matching field, usually because the sample did not include every field the API returns.
fix:Add the missing field, or annotate the class with @JsonIgnoreProperties(ignoreUnknown = true).
cause:The generated code uses java.util.List for arrays but imports are not added.
fix:Add import java.util.List; at the top of the file.
cause:Several public classes were pasted into one file.
fix:Move each class to its own file, or make nested classes public static inner classes.
How developers use the JSON to Java class converter in practice
Keep only the private fields and annotate the class with @Data (or @Getter @Setter) — Lombok generates the same accessors at compile time.
For read-only responses, convert the generated fields into a record: public record User(Integer id, String name) {}. Jackson 2.12+ deserializes records natively.
If the API uses snake_case, rename the Java field to camelCase and annotate it with @JsonProperty("created_at"), or configure PropertyNamingStrategies.SNAKE_CASE on the ObjectMapper.
When not to use the JSON to Java class converter
JSON to Java class converter limits and implementation notes
Optional fields missing from the sample will be missing from the class.
Integer, Double and Boolean are used so null is representable; switch to primitives where a value is always present.
Related guides
Standards & references
Related developer tools
Frequently asked questions about the JSON to Java class converter
What is a POJO generated from JSON?
A POJO (Plain Old Java Object) is a simple class with private fields and public getters and setters. Generating it from a JSON sample gives you a model that Jackson or Gson can map the JSON into without writing every field by hand.
Does the generated class work with Jackson and Gson?
Yes. Field names match the JSON keys and every field has a getter and setter, which is the convention Jackson and Gson use by default. Add annotations such as @JsonProperty only when you want Java names that differ from the JSON keys.
How are JSON types mapped to Java types?
Strings become String, whole numbers Integer, decimals Double, booleans Boolean, arrays List<T> and nested objects their own class. Wrapper types are used instead of primitives so that missing or null values can be represented.
Can I generate interfaces instead of classes?
Yes. Switch the target to Java Interface to get one interface per object with getter signatures only, which is useful for read-only views or proxies.
Do I need to add imports?
If the JSON contains arrays, add import java.util.List; to the file. Put each public class in its own file (or make nested ones static inner classes) to satisfy the Java compiler.
Is my JSON sent to a server?
No. Class generation runs entirely in your browser; the JSON is never uploaded.
Can I use generated Java classes with Lombok or as Java records?
Yes. The generated POJOs with getters and setters can be refactored into Java 14+ records for immutable models, or annotated with Lombok @Data or @Getter/@Setter to reduce boilerplate code.