CoreJSON

JSON to Java

This JSON to Java tool generates a Java POJO with fields, getters/setters and type inference from an API response. It supports three annotation styles — Jackson, Lombok + Jackson and a plain POJO — plus a custom package name. Generation runs locally in a Web Worker, so API data is not uploaded.

Open in the workbench Runs locally · nothing is uploaded

How to use it

  1. 1

    Paste your JSON

    Paste one representative JSON response; nested objects and arrays produce related classes (such as Address or List<String>).

  2. 2

    Configure style and package

    Choose Jackson, Lombok or a plain POJO, enter a package name (such as com.example.model) and optionally change the root class name.

  3. 3

    Copy the Java code

    Code is generated after you pause typing; copy the .java output into your project and split out extra inner classes as needed.

  4. 4

    Wire into your project

    Drop the classes into your model package and deserialise the response with your chosen library.

Key features

Three annotation styles

Jackson (@JsonProperty), Lombok (@Data to remove boilerplate) or a dependency-free plain POJO, switchable at any time.

Smart type inference

Integers are inferred as long and decimals as double, and nullable fields combine multiple samples to pick the widest type, reducing manual fixes.

Configurable package and root name

The package declaration and top-level class name follow your project convention, and non-ASCII keys are normalised into legal identifiers.

Local generation, no upload

The core engine runs in a browser Worker, so internal network and sensitive API payloads can be handled safely.

Getters and setters included

The Jackson and plain-POJO styles come with accessor methods ready for frameworks that need them.

Nested classes in one file

All related classes are emitted together so you can split them into separate files according to the package structure.

Common errors & troubleshooting

  • ! A null in a single JSON sample cannot reveal the real type, so paste samples of several different responses to improve inference (multi-sample input comes later).
  • ! A Spring Boot project already includes Jackson, so the Jackson style works out of the box; for the Lombok style make sure the Lombok plugin is installed.
  • ! A field name with an underscore (user_id) becomes userId in camel case, while the Jackson annotation keeps the mapping to the original JSON key.
  • ! The generated code assumes a package structure, so create the matching directories before pasting the file.

Frequently asked questions

Does the generated Java class work with Gson?

The plain POJO style binds to no framework and can be deserialised by Gson or Fastjson directly. Jackson @JsonProperty annotations are not shared with Gson, so for Gson annotations choose the plain POJO style and add @SerializedName by hand.

How are nested objects and arrays generated?

A nested object becomes a separate class (such as Address), a string array becomes List<String> and an array of objects becomes List<Address>. All classes are output in one document — split them into files according to the package structure.

Why is a number a long by default instead of Integer?

An API field may exceed the int range, so the wider long type is used by default to avoid overflow. When you are sure a field is small, such as a status code, change it to int by hand.

Is my JSON uploaded?

No. Generation runs in a Web Worker inside your browser, so internal and sensitive payloads stay on your machine.

Related tools