JSON to Java POJO Generator

Generate Java classes with fields, getters and setters from a JSON sample. Free, private and instant: everything runs in your browser.

JSON sample
Java classes
Result appears here as you type

What does the JSON to Java POJO Generator do?

A JSON to Java converter reads a sample JSON object and generates a POJO class for every nested object, with correctly typed private fields (String, int, long, double, boolean, List<T>), getters and setters. Keys that are not valid Java names get a Jackson @JsonProperty annotation.

How to use the JSON to Java POJO Generator

  1. 1

    Paste your json sample

    Paste or type json sample into the input box, open a file from your device, or click Sample to load an example.

  2. 2

    Adjust the options

    Set root class to match what you need.

  3. 3

    Copy or download the result

    Review the java classes on the right, then copy it to the clipboard or download it as a .java file.

JSON to Java POJO Generator example

Input
{"id":101,"first-name":"Asha","active":true,"balance":2450.75,"address":{"city":"Pune","pin":"411001"},"orders":[{"orderId":"A1","total":499}]}
Output
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;

public class Root {
    private int id;
    @JsonProperty("first-name")
    private String firstName;
    private boolean active;
    private double balance;
    private Address address;
    private List<Order> orders;

    public int getId() { return id; }
    public void setId(int id) { this.id = id; }

    public String getFirstName() { return firstName; }
    public void setFirstName(String firstName) { this.firstName = firstName; }

    public boolean isActive() { return active; }
    public void setActive(boolean active) { this.active = active; }

    public double getBalance() { return balance; }
    public void setBalance(double balance) { this.balance = balance; }

    public Address getAddress() { return address; }
    public void setAddress(Address address) { this.address = address; }

    public List<Order> getOrders() { return orders; }
    public void setOrders(List<Order> orders) { this.orders = orders; }
}

public class Address {
    private String city;
    private String pin;

    public String getCity() { return city; }
    public void setCity(String city) { this.city = city; }

    public String getPin() { return pin; }
    public void setPin(String pin) { this.pin = pin; }
}

public class Order {
    private String orderId;
    private int total;

    public String getOrderId() { return orderId; }
    public void setOrderId(String orderId) { this.orderId = orderId; }

    public int getTotal() { return total; }
    public void setTotal(int total) { this.total = total; }
}

When to use it

  • •Creating DTOs for Spring Boot REST clients
  • •Mapping third-party API responses with Jackson or Gson
  • •Saving time on boilerplate for Android apps

Why use this json to java pojo generator

  • 100% free, no signup or login
  • Runs locally: your data never leaves the browser
  • Instant results with clear error messages
  • Works on desktop, tablet and mobile
  • Copy to clipboard or download in one click
  • No watermarks and no usage limits

Frequently asked questions

Which JSON library are the classes for?+

The classes are plain Java and work with Jackson and Gson. When a JSON key is not a valid Java identifier (like "first-name"), a Jackson @JsonProperty annotation keeps the mapping correct.

Is the JSON to Java POJO Generator free?+

Yes. The JSON to Java POJO Generator is 100% free with no signup, no login, no usage limits and no watermark. It works on desktop and mobile browsers.

Is my data uploaded when I use the JSON to Java POJO Generator?+

No. The JSON to Java POJO Generator runs entirely in your browser with JavaScript. Nothing you paste or upload is sent to our servers, logged or stored.

Last updated by the Imaginex AI team.