JSONPOJO Generator

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.
Classes 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.

More free tools