JSON to Java Class (POJO)
Paste JSON, get Java classes (one file each) that Jackson can read.
One JSON document, or several samples one after another or one per line (JSON Lines). Comments and trailing commas are ignored. Your data stays in this browser.
Type inference
About the JSON to Java Class (POJO)
Paste a JSON response and get Java classes for it — one class per file, in your package. Choose plain POJOs (private fields with getters and setters), or Jackson-annotated classes whose @JsonProperty names keep every JSON key exactly, plus a Converter class with fromJsonString and toJsonString. Nested objects become their own classes, arrays List<T> or T[], integers long, decimals double, dates OffsetDateTime / LocalDate (or java.util.Date), UUIDs UUID; values that can be missing or null use the boxed types (Long, Double, Boolean).
Tick Lombok to get @lombok.Data instead of hand-written accessors, and download every .java file as a ZIP with the package folders already in place. Generation runs in your browser, so nothing you paste is uploaded.
How to use it
- Paste JSON or open or drop a .json file, or press Load sample. Several samples one after another (or JSON Lines) give more accurate optional fields.
- Set the Root class name and the Package.
- Choose Jackson annotations (with a Converter class) or Plain POJOs, and optionally Lombok, the date types and
List<T>or arrays. - Pick a file in File to see one class, or All files to see them together.
- Copy the code, download the selected
.javafile, or Download all (.zip) — the ZIP hascom/example/model/…folders that match the package.
Examples
{"id": 1, "employeeId": 7, "fullName": "Lata", "active": true, "score": 2.5}public class Employee {
private long id;
private long employeeId;
private String fullName;
private boolean active;
private double score;
public long getId() { return id; }
public void setId(long value) { this.id = value; }
…
}Root class name Employee, style Plain POJOs.
[{"role": "admin"}, {"role": "in-progress"}, … 12 users with three roles]public enum Role {
ADMIN, IN_PROGRESS, VIEWER;
@JsonValue
public String toValue() { … return "in-progress"; … }
@JsonCreator
public static Role forValue(String value) throws IOException { … }
}{"id": 1, "name": "x"}package com.example.model;
@lombok.Data
public class Item {
private long id;
private String name;
}Root class name Item, Plain POJOs with Lombok.
Common uses
- Creating request and response classes for a Spring Boot, Quarkus or Android REST client.
- Reading webhook payloads or JSON config files with Jackson.
- Turning a JSON Schema into model classes, like jsonschema2pojo, without installing anything.
- Getting a starting point for DTOs with Lombok.
Jackson classes or plain POJOs?
- Jackson annotations: every getter and setter has
@JsonProperty("…"), so JSON names such asuser_idoruserURLmap to Java names (getUserId(),getUserUrl()). Enums get@JsonValue/@JsonCreator, so a value like"in-progress"maps toIN_PROGRESS.Converter.fromJsonString(json)sets up anObjectMapperthat ignores unknown properties, registers the modules on the classpath (findAndRegisterModules()) and parses ISO date-times. Addjackson-databind(andjackson-datatype-jsr310for java.time) to your build. - Plain POJOs: no annotations and no dependencies. Jackson and Gson then match JSON names to bean or field names, which works for camelCase keys such as
employeeId— the notes list any keys that cannot match (snake_case, dashes, runs of capitals, keywords).
The output for the sample data was compiled with javac 21 in both styles, and the Jackson version was run against Jackson 2.16 to read and write the sample JSON.
Dates, numbers and missing values
- ISO 8601 date-times become
OffsetDateTime, datesLocalDateand timesOffsetTime(java.time); choose java.util.Date for older code. Untick Detect dates to keep them asString. - The generated Converter parses date-times into UTC:
"2026-08-02T18:02:11+05:30"comes back as2026-08-02T12:32:11Z— the same instant, written in UTC. - Whole numbers are
long, numbers with decimalsdouble; a value that can be missing ornullusesLong,DoubleorBoolean, so "not sent" isnullrather than0orfalse. - Java has no unsigned or 128-bit integers; the notes warn about integers that do not fit in 64 bits.
Limitations
- Types are inferred from your samples only — paste several real responses for accurate optional fields.
- The output is classic classes with getters and setters (or Lombok); Java records and builders are not generated.
- Lombok needs the Lombok dependency and annotation processing in your build; with Lombok on, the class has fields only.
- JSON Schema references must point inside the schema (
#/$defs/…), and validation keywords such aspatternare not turned into Bean Validation annotations.
Privacy
Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot. The code generator (about 330 KB compressed) is downloaded from this site once, like the rest of the page; your JSON is never uploaded.
Frequently asked questions
Is my JSON uploaded?
No. The classes are generated in your browser, in a background worker, and the page works offline once it has loaded.
Why is a getter called getUserUrl() when my JSON key is userURL?
Java names use camel case for acronyms (userUrl, getId), as in most style guides. With Jackson annotations the @JsonProperty("userURL") keeps the JSON name exact; with Plain POJOs such keys are listed in the notes because a library would look for userUrl instead.
Which Jackson version is needed?
The generated code uses long-standing Jackson 2 APIs (ObjectMapper, @JsonProperty, @JsonCreator, @JsonValue); the comment in Converter.java names 2.9.0 as a minimum. It was tested with Jackson 2.16.
How do I read a top-level JSON array?
Name the root after one item (for example User) and keep the array as the input: Converter.fromJsonString(json) then returns List<User> (or User[] with arrays).