JSON to Java POJO Converter

Paste JSON, get Java classes — fields, getters, setters, nested types and Jackson annotations.

In-browser & private
Advertisement
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, or long if it will not fit. If any sample of the same field has a decimal point, the field becomes double — or BigDecimal if you tick the box, which is the right choice for money.
  • Optional fields are boxed. A field that is null anywhere, or missing from some elements of an array, becomes Integer rather than int — 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 .java file 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_name becomes fullName and 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.time types 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"), so ObjectMapper and Spring's bind them unchanged. Unknown properties are ignored on POJOs, so a payload that grows a field later still deserialises.
Why does my Instant or LocalDate field fail at run time?
Because java.time types need the JSR-310 module. A bare ObjectMapper answers "Java 8 date/time type not supported by default" until you add com.fasterxml.jackson.datatype:jackson-datatype-jsr310 and register JavaTimeModule. Spring Boot does both for you. Untick "Map ISO dates to java.time" to get plain String fields instead.
Why is a field Integer instead of int?
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>.

More free tools