Advertisement

JSON to Java Class (Record / POJO) Generator

Convert JSON to Java records, POJOs with getters and setters, or Lombok @Data classes, with nested classes, List<> types and Jackson @JsonProperty names.

Paste a JSON sample and get Java classes that Jackson can read straight away. Choose compact records (Java 16+), classic POJOs with getters and setters, or Lombok @Data classes. Nested objects become nested static classes in one paste-ready file, arrays become List<…>, and keys that are not valid Java names are renamed to camelCase with an @JsonProperty annotation that keeps the original key.

How to use this tool

  1. Paste a JSON object, or a list of objects to merge several samples.
  2. Set the root class name and, optionally, a package.
  3. Choose records, POJO or Lombok.
  4. Keep Jackson annotations on if keys use snake_case, dashes or other non-Java names.

Formula

string → String · whole number → int (long outside −2,147,483,648…2,147,483,647) · decimal → double · true/false → boolean · object → nested class · array → List<item type> · null or missing → Integer, Double, Boolean · mixed → Object

Primitives cannot hold null, so a key that is null or absent in any sample gets the wrapper type. Field names are camelCase: user_name becomes userName, and Java keywords get a suffix, so class becomes classValue. @JsonProperty is added when the Java name differs from the key, or when the second letter is upper-case, where Jackson’s getter naming would otherwise change the key. Numeric inference uses JavaScript numbers, so integer samples must stay within ±9,007,199,254,740,991. Use strings for larger identifiers or exact decimals. With Jackson enabled, POJO/Lombok models bind fields directly to prevent getter aliases from duplicating keys. Empty JSON keys must be renamed first.

Example

From the default sample the tool writes 3 classes and 16 fields: User, plus nested Address and Order. "id": 1024 becomes int id, "balance": 1520.75 becomes double balance, and "tags" becomes List<String> tags. Both orders have total, and because 59.9 is fractional it is double total. order_id is renamed orderId with @JsonProperty("order_id"), and "lastLogin": null becomes Object lastLogin, since null alone carries no type.

Frequently asked questions

Record, POJO or Lombok?

Records need Java 16+ and Jackson 2.12+. POJOs use explicit getters and setters. Lombok @Data generates accessors during compilation and requires its dependency and annotation processor. The generated Jackson annotations use the Jackson 2.x packages.

Why int in one place and Integer in another?

A primitive int cannot be null. When a key is null or missing in any sample, the generator uses Integer so an absent value stays null instead of silently becoming 0.

Why is the getter for isActive called isIsActive()?

In POJO mode a primitive boolean getter uses is plus the full field name, giving isIsActive(). Lombok may shorten isActive to an active property; the generated alias preserves the JSON key when Jackson annotations are enabled.

Can I use this with Gson?

Yes, where names match. Gson reads fields directly and uses its own @SerializedName annotation, so turn Jackson annotations off and add @SerializedName to renamed fields.

Sources

Last updated: 2026-10-30

Advertisement