JSON to Java POJO Converter
Paste JSON, get Java classes — fields, getters, setters, nested types and Jackson annotations.
In-browser & private
JSON
Ctrl + Enter to generate
Java
Paste JSON on the left, or press Sample.
Types —
Fields —
Size 0 B
How the types are chosen
JSON carries values, not types, so a converter has to infer them. This one reads every sample of a field before deciding, which is what stops a list of objects turning into a pile of near-identical classes.
- Numbers widen. A whole number becomes
int, orlongif it will not fit. If any sample of the same field has a decimal point, the field becomesdouble— orBigDecimalif you tick the box, which is the right choice for money. - Optional fields are boxed. A field that is
nullanywhere, or missing from some elements of an array, becomesIntegerrather thanint— otherwise the class could not hold the very document it was generated from. - Repeated shapes are merged. The same object appearing in several places produces
one class, not
Address,Address2,Address3. - Nested classes are nested. A
.javafile may hold one public top-level type, so inner types are emitted inside the root as static members — the output is one file you can paste and compile. - Names are converted, not renamed.
full_namebecomesfullNameand carries@JsonProperty("full_name")so it still binds.
Want immutable Java 17 records instead of classes? The JSON to Java Record converter shares this type inference.
Frequently asked questions
- Is my JSON uploaded anywhere?
- No. The conversion runs entirely in your browser. Nothing you paste leaves the page, which is why production payloads with real customer data are safe to use here.
- Which Java version does the output need?
- Plain POJOs and Lombok classes compile on Java 8 and later. Records need Java 17 or later.
The
java.timetypes need Java 8 or later. - Does the generated code work with Jackson and Spring Boot?
- Yes. Keys that are not valid Java names, such as
full_name, become camelCase fields with("full_name"), soObjectMapperand Spring'sbind them unchanged. Unknown properties are ignored on POJOs, so a payload that grows a field later still deserialises. - Why does my
InstantorLocalDatefield fail at run time? - Because
java.timetypes need the JSR-310 module. A bareObjectMapperanswers "Java 8 date/time type not supported by default" until you addcom.fasterxml.jackson.datatype:jackson-datatype-jsr310and registerJavaTimeModule. Spring Boot does both for you. Untick "Map ISO dates to java.time" to get plainStringfields instead. - Why is a field
Integerinstead ofint? - Because it was
null, or missing, somewhere in your sample. A primitive cannot hold null, so the class would fail on the very document it was generated from. - Can I convert a JSON array?
- Yes. A top-level array is treated as a list of samples of one type, and the page tells you to
bind the whole document as
List<YourClass>.