{ }jsonkit
Format
Validate
Convert
Query
Generate

JSON to Java records and classes

Turn sample JSON into Java 17 records or POJO classes.
Style
219 B · paste or drop a file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
✓ complete219 B → 233 B0.0 ms

About JSON to Java

Convert JSON to Java objects online. Paste a sample document and get Java 17 records or classic POJO classes that match its shape, ready for a Spring or Jackson project.

Nested objects become their own types, arrays become List generics, and keys that are not valid Java names get Jackson @JsonProperty annotations. Runs in your browser. Nothing is uploaded.

How it works

Records or classes

Choose Records for compact Java 17 records like public record User(String id, ...) {}. Choose Classes for POJOs with private final fields and public getters. Records suit immutable DTOs. Classes suit older Java versions and frameworks that expect getters.

Type inference

Strings become String, whole numbers long, decimals double, and true or false boolean. A null or empty field becomes Object, because the sample cannot show its real type. Each nested object becomes its own named record or class.

Arrays and List generics

JSON arrays become List<X>, with X inferred from the elements. You get List<String>, a named element type for arrays of objects, or List<Object> for empty or mixed arrays. java.util.List is imported only when a List appears.

Jackson annotations

With Jackson annotations on, a key that is not a valid camelCase Java field, like first-name or user_id, gets @JsonProperty("original-key") so deserialization still maps it. The Jackson import is added only when at least one annotation is used.

Frequently asked questions

Does it generate Java records or classes?

Both. Pick Records for Java 17 records, or Classes for POJOs with private final fields and getters. The Style control switches between them.

How are numbers typed?

Whole numbers become long and decimals become double. A single sample cannot prove the intended range, so change them to int, Integer or BigDecimal where needed.

When does it add @JsonProperty?

Only when Jackson annotations are on and a JSON key differs from its camelCase field name. For example, first-name maps to a firstName field with @JsonProperty("first-name"). Matching keys get no annotation.

Can I paste production API responses safely?

Yes. Conversion runs in your browser, and the JSON is never uploaded or logged.

Why did a field come out as Object?

The sample did not carry enough information. A null, an empty array or a mixed array cannot show a concrete Java type, so it falls back to Object. Use a fuller example or set the type by hand.

Sources & last verified

We checked this tool's behavior and the claims on this page against the specifications below on . The tool runs in your browser, so the output you see is exactly what the engine produced.

Found a wrong result or an outdated claim? Report an error and we will check it again.