JSON to Java

Convert JSON into Java POJO classes with nested models, collection types, and optional getters and setters.

Runs locally in your browser
JSON Input
Java Output
import java.util.List;

// Generated from JSON.
// Review field types and adapt the models to your application.

class Profile {
    private String country;
    // Optional field: may be absent or null.
    private Object timezone;

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public Object getTimezone() {
        return timezone;
    }

    public void setTimezone(Object timezone) {
        this.timezone = timezone;
    }
}

class ProjectsItem {
    private String name;
    private Integer stars;
    // Optional field: may be absent or null.
    private Boolean active;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getStars() {
        return stars;
    }

    public void setStars(Integer stars) {
        this.stars = stars;
    }

    public Boolean getActive() {
        return active;
    }

    public void setActive(Boolean active) {
        this.active = active;
    }
}

public class GeneratedModel {
    private Integer id;
    private String name;
    private String email;
    private Boolean isActive;
    private List<String> roles;
    private Profile profile;
    private List<ProjectsItem> projects;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    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;
    }

    public List<ProjectsItem> getProjects() {
        return projects;
    }

    public void setProjects(List<ProjectsItem> projects) {
        this.projects = projects;
    }
}

Generation notes

  • • Nested objects become separate Java classes.
  • • Object arrays merge fields from all objects.
  • • Missing or null fields use reference or wrapper types.
  • • Arrays are represented using List collection types.
  • • Only the root class is public; helper classes are package-private.

How to use JSON to Java

  1. 1Paste a valid JSON object or array.
  2. 2Choose the root class name and generation options.
  3. 3Copy or download the generated Java code.