RealJSON
Try now

JSON to Java Record Converter

Paste any JSON and get Java records instantly — nested types, arrays and optional fields included.

Root type name

JSON input

Java records

 

In short: A JSON to Java converter writes Java record types for a JSON document, annotated with Jackson @JsonProperty. Nested objects become their own records and arrays become List<T>.

JSON to Java Converter

Writing Java records by hand for every API response is slow and easy to get wrong. This tool infers the types from real data: it merges every item of an array, so a field that is missing from some items is marked optional instead of being silently dropped.

Deserialize with new ObjectMapper().readValue(json, Root.class). Records require Java 16+ and Jackson 2.12+. Everything runs locally in your browser — safe for private payloads.

How the Conversion Works

Type mapping

strings → String, integers → long, decimals → double, booleans → boolean (boxed types when null or optional), arrays → List<T> and unknown values → Object.

Null and optional fields

Nullable and optional fields use boxed types (Long, Boolean) so they can hold null.

Naming

Keys are converted to camelCase component names; @JsonProperty("original-key") keeps the mapping to the JSON key.

Frequently Asked Questions

How do I convert JSON to Java?

Paste your JSON, set a root type name, and Java records are generated instantly. Copy the result or download it as a .java file.

How are nested objects and arrays converted to Java?

Each nested object becomes its own named type and arrays use the element type inferred from all of their items, so arrays of objects are fully typed.

How are null and missing values handled?

Nullable and optional fields use boxed types (Long, Boolean) so they can hold null.

Why records instead of classes with getters?

Records are concise, immutable and supported by Jackson 2.12+ and Java 16+. If you need mutable POJOs, copy the fields into a class and add Lombok or getters/setters.

Is my JSON sent to a server to generate the Java records?

No. Generation runs entirely in your browser — your JSON never leaves your device.

Related Tools

JSON to TypeScript · JSON to JSON Schema · JSON Validator · JSON Formatter

Browse all free JSON tools →

Related tools