JSON to Java Class Generator
Generate Java records or Jackson-annotated classes from a JSON sample, with nested types, List fields and @JsonProperty for keys that are not valid Java names.
Free · No sign-up · Your inputs stay in your browser
Input
Generate Java types from JSON
Output
Java
427 characters
Records are immutable and need Jackson 2.12 or later to deserialise. Whole numbers become Long and fractions Double, boxed so a missing value can be null. A key that is not a valid Java name keeps its JSON name through @JsonProperty. Types come from this one sample: give fields that are null here a real value to type them.
Runs in this browser. Nothing you paste is sent to a server.
About this tool
Method, assumptions, practical next steps, and limits.
Records or classes
Records (Java 16 and later) are immutable and need no getters, which suits data transfer objects; Jackson has deserialised them since 2.12. Classes with getters and setters are what older frameworks and JPA entities expect. Both outputs here compile against com.fasterxml.jackson.annotation and java.util.List.
Types to review
Long is chosen for every whole number because it never overflows where Integer might; narrow it if the API documents a smaller range. Money arrives as Double from a sample and belongs in BigDecimal, which Jackson reads when DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS is enabled or the field is declared BigDecimal.