Code generation

JSON to Java

Generate Java model classes from JSON locally.

Accepts an object or a non-empty array of objects. POJOs use public fields; records use components. Jackson requires jackson-annotations; Lombok requires its dependency and annotation processor. Generate again after changing options.

Input JSON
Java output

What is JSON to Java?

Infer simple Java model classes from a JSON example in your browser. Nested objects become their own classes, arrays become typed lists, and field types are guessed from the sample values — so you get a starting point for POJOs without hand-typing boilerplate.

How to use JSON to Java

  1. Paste a JSON object or a non-empty array of objects, or load the nested example.
  2. Choose the root class, optional package, POJO or record mode, and optional dependencies.
  3. Generate Java, review inferred types, and copy or download the single file using its root class name.

Example

{"order-id":42,"customer":{"name":"Ada"},"items":[{"sku":"A1","quantity":2},{"sku":"B2","price":4.5}]}

// POJO fields (nested classes are included in the download):
public Integer order_id;
public Customer customer;
public List<ItemsItem> items;
// ItemsItem has String sku, Integer quantity, Double price.

Limitations and details

All object samples in an array contribute fields. Missing and null values use nullable boxed types; null-only values and empty arrays infer Object and List<Object>. Mixed incompatible values infer Object. Integers infer Integer or Long; decimals infer Double. Duplicate JSON keys collapse to the last value. JavaScript parsing can round decimals, and large unsafe integers are rejected: use strings for exact financial values or large IDs. Keys are sanitized and collisions get numeric suffixes. Enable Jackson annotations to retain original JSON names. POJOs use public fields, with optional Lombok @Data. Records require Java 17+; POJOs require Java 8+. Jackson annotations and Lombok require their respective dependencies. Samples are limited to 1,000,000 characters, 40 nesting levels, and 200 model types. Inference is a starting point, not a complete schema.

Practical guide

Generate Java POJOs from nested JSON for Spring Boot

Frequently asked questions

Is JSON uploaded?

No. Generation runs in your browser.

How are nested objects handled?

Each nested object in your JSON example becomes its own Java class, referenced as a field on the parent class.

What Java types are used?

Types are inferred from the sample values: strings, numbers, booleans, lists, and nested object classes. Review and adjust types for edge cases your sample doesn't cover.