JSON to Java
Generate Java model classes from a JSON object. Choose a Java record, a plain POJO with getters and setters, or a Lombok @Data class. Runs locally in your browser.
Generate Java classes from JSON
Modelling a JSON payload in Java usually means a lot of boilerplate — fields, getters, setters, constructors — or careful use of records and annotations. Paste a JSON sample and this tool writes the model for you in the style you choose: a modern Java record, a classic POJOwith getters and setters, or a Lombok @Data class. Nested objects become their own classes and arrays become typed Lists, so the output drops straight into a Spring, Jakarta EE or plain-Java project.
How to use it
- Paste a JSON object into the input box.
- Pick the Style (record, POJO or Lombok) and set the Root class name.
- Copy the generated Java on the right into your project.
A worked example
This JSON:
{ "id": 10, "name": "Ada Lovelace", "active": true }produces (record style):
public record Root(
Double id,
String name,
Boolean active
) {}Switch to POJO and you get a class with private fields plus matching getters and setters; switch to Lombok and the same fields sit under a single @Data annotation.
When you would reach for it
Consuming a REST API in a Spring Boot service, deserializing a webhook, or mapping a config file. For other languages see JSON to TypeScript; to turn the same data into database tables, use JSON to SQL.
Privacy
Generation happens locally in your browser and works offline once loaded. Your JSON is never uploaded or stored, so it is safe to paste real payloads.
Frequently asked questions
Record, POJO or Lombok — which should I pick?
Use a record for immutable data carriers on Java 16+ (the most concise option). Pick POJO when you need mutable objects with explicit getters and setters, or must support older Java. Choose Lombok when your project already uses it and you want the brevity of records with mutability.
What number type is used?
Numbers map to Double, and integers/longs are also represented as Double for safety because JSON does not distinguish them — adjust to Long or Integer where your schema guarantees whole numbers.
Can it handle nested objects?
Yes. Each nested object becomes its own class, and arrays become List<T> with the element type inferred from the contents.
Does it add serialization annotations?
The classes use the original JSON key names as field names where they are valid Java identifiers. For keys that are not (for example user-id), add your library's annotation such as Jackson's @JsonProperty.
Which JSON library do these work with?
The generated classes are plain Java and work with Jackson, Gson or any reflective mapper. Records are supported by Jackson 2.12+ and Gson 2.10+.
Is my JSON uploaded?
No. Class generation runs entirely in your browser; nothing is sent to a server.