JSON to Java POJO Generator
Turn a JSON response into Java classes that actually deserialise: primitives where a value is required, wrappers where it is optional or null, @JsonProperty for keys Java cannot name, and nested objects as static classes.
Runs entirely in your browser — your JSON is never uploaded.
Free generation covers up to 1,000,000 characters per document — what Pro adds. The JSON you paste never leaves the tab; inference runs in your browser.
How to generate Java classes from JSON
- Paste a JSON object or array or load the example: two orders whose keys disagree on nullability, which is where most generated POJOs break.
- Name the root and set the package The root name becomes the public class and the file name. The package is optional — leave it blank for a snippet.
- Choose the mapping style Jackson annotations on by default, getters and setters on by default, 2 or 4 space indent. All three change the output live.
- Copy or download the .java file One file with every nested class. Drop it into src/main/java and run your mapper against the same payload you pasted.
Primitive or wrapper: the decision that decides whether it parses
Java’s type system forces a choice that JSON does not: a long cannot hold null. Every field therefore has to answer “can this be absent?” before it can be declared, and getting it wrong produces the classic failure — a NullPointerException on a field the sample never showed as missing, or a silently zeroed primitive.
- Present in every sample → primitive.
long total. No boxing, no null checks, and the mapper fails loudly if the API ever stops sending it. - Missing from any sample → wrapper.
Long total. The distinction comes from sampling every array element, not just the first: paste a single record and every field looks required. - ever null → wrapper.
Double discountfor a field that heldnullin one record. A primitive cannot represent that, and Jackson will throw on the null rather than coerce it. - Generics are always boxed.
List<Long>, neverList<long>— Java generics only accept reference types, which is a compile error waiting for anyone who tries.
The same rule decides boolean versus Boolean and double versus Double. Whole numbers get long rather than int because 32 bits overflow on timestamps and totals; if you know a field is small, narrowing it is a safe manual edit. Floats are double, never float, and money should not be a double at all — see the precision guide for the BigDecimal argument.
Names: the part JSON and Java refuse to share
coupon_code is not a legal Java convention, so the field becomes couponCode — and now the mapper cannot find it. The wire name has to be preserved explicitly:
- With Jackson on (default):
@JsonProperty("coupon_code")sits directly above the field, so both names survive. - With Jackson off: the key is kept as a trailing comment,
private String couponCode; // json: coupon_code. Pick a mapper that can be configured with a naming policy, or turn the annotation back on. - Keys that break the rules: a key starting with a digit gets a
fieldprefix (2fa_enabled→field2faEnabled), because an identifier cannot start with a number.
One file, nested static classes
A JSON document with four nested objects could become five Java files, since only one public top-level class is allowed per file. This generator takes the other route: nested objects become public static class declarations inside the root. The result is one file you can paste and compile, with types named after their path — Order → OrderCustomer → OrderItems.
When the root of the document is an array, the file models one element and says so in a comment: Java needs a class, and inventing a wrapper object the API never sends would be worse than a comment explaining List<Order>.
Every one of these decisions is only as good as the sample behind it: paste one record and nothing looks optional. The argument is laid out in your sample is not a schema, and it applies to Java unchanged. For the parts that are Jackson-specific — primitive versus boxed, null versus absent, records and nested classes — read primitive or boxed, and why it matters.
DevTinyTools Pro
The free generator handles the payloads most people paste by hand. Pro raises the document cap and unlocks every other tool on the site:
- 10,000,000-character documents, roughly 10 MB of JSON
- The same Pro licence unlocks every tool on the site — TypeScript, Go, schemas, batch ZIP export
- Priority fixes — generation bugs move to the front of the queue
Pro is $29 one-time — a lifetime licence, sold through Lemon Squeezy as merchant of record, so VAT and sales tax are handled for you. Pro is a licence key — there is still no account. Buy DevTinyTools Pro, then activate it below and the higher limits unlock in this browser.