JSON to Java Classes Converter

Paste JSON to generate Java POJOs, Lombok classes, or Java Records. 100% client-side.

Last reviewed: June 2026

New to this tool? Click here for instructions

JSON Input
Java Output
Paste JSON above to generate Java classes.

How to Convert JSON to Java Classes

Paste a JSON object or an array of objects into the left pane. The converter parses the JSON in your browser and updates the Java output automatically; there is no separate Convert button.

Choose POJO, Lombok, or Record mode depending on the code style you need, then copy or download the generated draft class. The Try Example button loads a nested sample so you can see how child objects and arrays are handled.

  • POJO: Classic Java class with private fields, public getters, and public setters.
  • Lombok: Adds @Data, @NoArgsConstructor, and @AllArgsConstructor.
  • Java Record: Java 16+ record syntax, immutable, and useful for read-only API response models.

When to Use This Tool

Use this converter when you are exploring an API response, building DTOs for a Java client, or moving from a quick JSON sample to a typed model. It is most useful at the first-draft stage: generate the shape, paste it into your IDE, then add package names, imports, validation annotations, and JSON library annotations as needed.

How It Works

The browser runs JSON.parse(), walks the resulting object, and infers Java field types from the values it finds. Strings become String, integers become int or Integer, decimals become double or Double, booleans become boolean or Boolean, arrays become List<...>, nested objects become nested class definitions, and null values fall back to Object.

All conversion logic runs locally in JavaScript. Your pasted JSON is not uploaded, queued, logged, or sent to a remote conversion service.

Tips, Edge Cases, and Limitations

1. Field names: Simple JSON keys convert cleanly. Keys with spaces, hyphens, or reserved Java words may need manual cleanup or @JsonProperty annotations.

2. Arrays: The converter infers an array type from the first item. Mixed arrays may need a wider type such as List<Object> after review.

3. Numbers: Integer-looking values map to Java integer types; decimal-looking values map to floating-point types. Adjust to long, BigInteger, or BigDecimal when your domain requires it.

4. Dependencies: Lombok mode only emits annotations. Your project still needs the Lombok dependency and IDE annotation-processing support.

5. Compile check: Treat the output as a fast draft, then compile and test it with the JSON library used by your application.

Frequently Asked Questions

A Java POJO (Plain Old Java Object) is a simple Java class with private fields, public getters, and public setters. It follows the JavaBeans standard and is compatible with all Java JSON libraries.
Lombok's @Data annotation simplifies the process of creating Java classes by automatically generating getters, setters, equals, hashCode, and toString methods. This reduces boilerplate code and makes development faster and more efficient.
Java Records are a feature introduced in Java 16 that provide an immutable, compact representation of data. They are ideal for read-only API response models and can help reduce the amount of code you need to write.
Use the generated class as a starting point for Jackson, Gson, or another Java JSON library. Add annotations manually when a JSON key is not a valid Java bean property name, then deserialize with your normal ObjectMapper or adapter setup.
No, your JSON data is processed entirely on your device. ThisDevTool uses a client-side approach, ensuring your data remains private and secure.

Quick reference

JSON to Java Classes Converter Quick Reference
JSON shape Generated Java Mode notes Review before use
"name": "John" String name All modes Rename only if your Java style differs from the JSON key.
"age": 30 int age or Integer age Boxed in Lombok and Record modes Change to long for large API identifiers.
"score": 9.5 double score or Double score Boxed in Lombok and Record modes Use BigDecimal for money or exact decimal math.
"address": { ... } Address address Nested class generated from the key Add package structure or separate files manually.
"hobbies": ["reading"] List<String> hobbies Uses first array item for inference Mixed arrays may require List<Object>.

Example walk-through

Worked example: step-by-step

Step 1. Click Try Example or paste this JSON into the input area:


{
  "name": "John",
  "age": 30,
  "address": { "city": "NYC", "zip": "10001" },
  "hobbies": ["reading"],
  "active": true,
  "score": 9.5,
  "nickname": null
}

Step 2. Leave POJO selected if you want classic private fields with getters and setters, or switch to Lombok or Record mode to change the style.

Step 3. The output updates immediately. For the sample above, the converter generates a RootObject class plus an Address class.

Step 4. The POJO output starts like this:


public class RootObject {
    private String name;
    private int age;
    private Address address;
    private List<String> hobbies;
    private boolean active;
    private double score;
    private Object nickname;
}

public class Address {
    private String city;
    private String zip;
}

Step 5. Copy or download the draft, then add package declarations, imports, annotations, and any domain-specific type changes in your IDE.