JSONPOJO Generator
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.
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, 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.