Skip to content
AZ Tools

JSON to Java Class (POJO) Converter

Turn a JSON object into Java POJO classes with type-mapped fields, in your browser.

Java classes

How to use

  1. Paste or type your JSON into the input box.
  2. Optionally rename the root class (defaults to AutoGenerated).
  3. Copy the generated classes from the output box.
  4. The classes expose public fields rather than accessors — add getters, or a Lombok annotation, if your framework expects JavaBean methods.

About this tool

Show

Paste any JSON object or array and get ready-to-use Java class definitions (POJOs) with typed fields and separate classes for nested objects, each named after the key that held it. Numbers are mapped by their sample value: a whole number becomes long and a fractional one becomes double, both primitives, so a field that can arrive as null needs the boxed Long or Double instead. A JSON null falls back to Object, since one sample cannot reveal the intended type, and an empty array becomes List<Object>. Non-empty arrays are typed from their first element, which is the usual assumption for homogeneous JSON but worth checking on mixed data. Everything runs locally in your browser — your JSON is never uploaded.

Frequently asked questions

How are numbers typed?

Whole numbers become long and numbers with a decimal point become double. Change to int or float manually if you prefer a narrower type.

What happens with null or empty arrays?

null values map to Object and empty arrays to List<Object>, since their type can't be inferred from the sample.

How are nested objects handled?

Each nested object becomes its own class. An import for java.util.List is added when any list field is generated.

Is my JSON sent anywhere?

No. Conversion happens entirely in your browser; nothing is uploaded.

Why long and double rather than int and float?

Because a sample cannot show how large a value gets. An id that fits in an int today overflows the moment it passes two billion, and float loses precision on ordinary money amounts. The wide type is the safe default; narrow it when you know the range.

A field is sometimes null — what should I change?

Swap the primitive for its boxed form: long becomes Long, double becomes Double, boolean becomes Boolean. A primitive cannot hold null, so a JSON null would otherwise deserialize to zero or false and hide the fact that the value was missing.

Related tools