TXT · Text & Data tools

JSON to Java Class Converter

Top-level type
Arrays
Dates
Acronyms
Package
JSON input
Java output
Inference
JavalanguageJSON sampleinput0types0lines out0chars out
Go to the full JSON to Types generator with all ten languages

Shareable link

Settings are written to the URL as you change them. Nothing differs from the defaults yet.

Java classes from a JSON sample

Paste a JSON document and get one public class per object shape with private fields, Jackson-annotated accessors, and a converter that parses and writes the top-level type. Nested objects become their own classes; arrays become List<T>.

Example

package io.quicktype;

import com.fasterxml.jackson.annotation.*;
import java.util.List;

public class Customer {
    private long id;
    private String name;
    private List<Order> orders;

    @JsonProperty("id")
    public long getId() { return id; }
    @JsonProperty("id")
    public void setId(long value) { this.id = value; }

    @JsonProperty("orders")
    public List<Order> getOrders() { return orders; }
    @JsonProperty("orders")
    public void setOrders(List<Order> value) { this.orders = value; }
}

The Order class follows the same shape. A key present in only some orders, such as gift, becomes a boxed Boolean so a missing value is null rather than a failed decode.

Lombok

Check Lombok annotations to drop the hand-written accessors and emit @Data and @NoArgsConstructor on each class instead. The @JsonProperty annotations move onto the fields, and Copy accessor annotations controls whether Lombok is told to copy them onto the generated getters.

Dates and collections

Dates defaults to java.time, producing OffsetDateTime fields and a converter that registers the JavaTimeModule. Legacy produces java.util.Date. Arrays chooses List<T> or T[].

Limits

Java has no union type, so a field that mixes types in the sample becomes a small holder class with one nullable member per type and a custom deserializer. Repeated string values become an enum with a forValue factory when enum inference is on.

Frequently Asked Questions

Jackson. Each property gets @JsonProperty with the original key on its getter and setter, and a Converter class with fromJsonString and toJsonString is emitted unless Types only is checked.

Yes, one pair per field, each annotated with @JsonProperty. Check Lombok annotations to replace them with @Data and @NoArgsConstructor on the class.

As List<T> by default. Set Arrays to T[] for plain arrays.

Whole numbers are long and fractions are double. ISO 8601 strings become OffsetDateTime with java.time, or Date with the legacy provider, when date inference is on.

The Package field sets the package line; it defaults to io.quicktype. Change it before copying so the files land where your build expects them.

Generate types for one language

Full JSON to Types Generator tool

Explore Our Tools

Browse all tools