JSON to Java POJO

Convert JSON to Java classes, with optional Lombok annotations

Runs in your browserUtility02Converters

What is JSON to Java POJO?

This JSON to Java converter generates POJO definitions from sample data and annotates each field with @JsonProperty so the original key name survives. You can either lean on the Lombok @Data annotation or generate full getters and setters. The inference runs entirely in your browser.

How to use JSON to Java POJO

  1. 1Paste a sample JSON response.
  2. 2Enter the root class name. Nested objects become classes of their own.
  3. 3Decide whether to use Lombok based on your project conventions.
  4. 4After copying, split the output into separate files, since Java requires a public class to match its file name.

Frequently asked questions

Why use the wrapper type Long instead of the primitive long?+

A JSON field may be absent or null, and a primitive has no way to represent the absence of a value, so deserialization quietly fills in 0 and changes the meaning of your data. Wrapper types preserve null, at the cost of null checks in your business logic.

What still needs adjusting in the generated classes?+

Three things. Split each class into its own file and add the package declaration, add validation annotations to optional fields based on your API contract, and check whether any field type should be narrowed. Monetary amounts, for example, belong in BigDecimal rather than Double.

Related tools

All tools