{ }jsonkit
Format
Validate
Convert
Query
Generate
→java

JSON to Java Records & Classes

Infer Java 17 records or POJO classes from sample JSON.
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

The JSON to Java converter turns a sample JSON document into Java 17 records or classic POJO classes. Paste an API response and get typed Java source describing its shape, ready to drop into a Spring or Jackson project instead of hand-writing every field, constructor and getter.

Conversion runs entirely in your browser with no upload, so you can turn a real production payload into Java types without it ever leaving your machine. It is free and needs no account.

It is built for Java and Kotlin backend developers who consume JSON APIs and want accurate model classes fast, including the nested types, List generics and Jackson bindings they would otherwise write by hand.

How it works

Records or classes

Choose Records to emit compact Java 17 records — public record User(String id, ...) {} — or Classes to emit traditional POJOs with private final fields and public getters. Records suit immutable DTOs; classes suit codebases still on older Java or frameworks that expect getters.

Type inference

Types are inferred from the sample values: strings become String, whole numbers become long, decimals become double, true/false become boolean, and a null or empty field becomes Object because the sample can't reveal its real type. Nested objects become their own named record or class referenced by the parent.

Arrays and List generics

JSON arrays become List<X>, where X is inferred from the elements — List<String>, a named element record for arrays of objects, or List<Object> for empty or mixed arrays. java.util.List is imported automatically, and only when a List actually appears in the output.

Jackson annotations

With Jackson on, any JSON key that isn't a valid camelCase Java field — like first-name or user_id — gets an @JsonProperty("original-key") so deserialization still maps correctly. The com.fasterxml.jackson.annotation import is added only when at least one annotation is emitted, keeping clean payloads import-free.

Frequently asked questions

Does it generate Java records or classes?

Both. Pick Records for Java 17 immutable record types, or Classes for POJOs with private final fields and getters. Toggle the Style control to switch.

How are numbers typed?

Whole numbers become long and numbers with a decimal point become double. Because a single sample can't prove the intended width, widen or narrow to int, Integer or BigDecimal by hand where you need to.

When does it add @JsonProperty?

Only when Jackson annotations are on and a JSON key differs from the camelCase Java field name it maps to — for example first-name maps to a firstName field with @JsonProperty("first-name"). Keys that already match get no annotation.

Can I paste production API responses safely?

Yes. Conversion runs entirely in your browser, so the JSON you paste is never uploaded or logged.

Why did a field come out as Object?

The sample didn't carry enough information — a null value, an empty array or an array of mixed types can't reveal a concrete Java type, so it falls back to Object. Provide a fuller example or refine the type by hand.