🛠️ Developer & Web

JSON to Java Class Converter

Paste a JSON sample — get Java types instantly.

  • Freeno limits, no watermark
  • 0sign-ups or accounts
  • Privateruns on your device
  • Any devicephone, tablet or PC

How the types are inferred

The generator reads your sample and infers a type for every field: strings, integers and decimals, booleans, nested objects (each gets its own named Java type) and arrays. If an array holds several objects, all of them are merged — fields missing from some items become optional and fields that are sometimes null become nullable, so one representative response is usually enough. Field names that aren’t valid identifiers are converted and mapped back to the original JSON key.

Using the Java code

The output uses Java records (Java 16+) — compact, immutable data carriers that Jackson 2.12+ deserialises directly: new ObjectMapper().readValue(json, Root.class). @JsonProperty keeps the original JSON names while fields use camelCase. Nullable values use boxed types (Integer, Double, Boolean) so they can hold null. For older Java, convert each record into a class with private fields, getters and a no-args constructor.

Everything runs in your browser — your code and data are never uploaded, so it is safe to paste private config files and API responses.

Frequently asked questions

Which Java version do records need?

Java 16 or newer.

Does it work with Gson?

Gson 2.10+ supports records; replace @JsonProperty with @SerializedName.

Why Integer instead of int?

Boxed types can be null when the JSON value is null or missing.

Found it useful? Share the JSON to Java Class:

Last updated 2026-11-21 · Built by Vinayak Agarwal · Part of Developer & Web (77 tools)