JSON to Java classes

Paste JSON and get Java records or classic classes with getters and setters. Jackson @JsonProperty annotations keep keys that do not match Java names.

Free and private. Everything runs in your browser, nothing is uploaded.

How it works

  1. Paste your JSONPaste a response from your API or open a .json file. Use Sample to see an example.
  2. Adjust the optionsSet the name of the top level type and the options for this language. The code updates as you type.
  3. Copy or downloadCopy the code into your project or download it as a file.

Records or classic POJOs

Records, available since Java 16, are the shortest way to model a JSON object and Jackson reads them without extra setup. If your project uses an older Java version or a framework that needs setters, choose classes: you get private fields with getters and setters for every property.

Field names are camelCase. Required numbers and booleans use primitive types such as int and boolean, while optional or nullable ones use Integer, Long or Boolean so they can hold null. ISO dates become LocalDate, LocalDateTime or OffsetDateTime; Jackson needs the jackson-datatype-jsr310 module to read them. All types are in one file: the top level type is public and the others are package private, so the file name must match the top level type.

Frequently asked questions

Does it work with Gson?

Yes, the classes work with Gson too. Turn off the Jackson annotations and use @SerializedName where the Java name differs from the key.

Is my JSON uploaded anywhere?

No. The types are generated in your browser. API responses with customer data or keys never leave your device.

How are optional fields detected?

If the JSON contains a list of objects, every object is compared. A field that is missing from at least one object is marked optional. With a single object, every field is treated as required.

What happens with fields that are always null?

The type cannot be known from the sample, so the field gets a general type such as unknown, object, Any or JsonElement. Add a sample where the field has a value to get a precise type.

Why is my 1.0 typed as a decimal number?

The tool looks at how the number is written. 1.0 or 2.5 become double or float, 1 becomes an integer. If a field is whole in some items and decimal in others, the decimal type is used.

Can I use the result in production code?

Yes, the code compiles as it is in the usual setups. Review names and types before you commit it, because a sample can never show every possible value.

Does it work offline?

Yes. After you open the page once, it keeps working without an internet connection.