JSON to Java Converter

Generates Java POJO classes from JSON with correct field types, a no-arg constructor, and optional getters and setters — or swaps to Lombok annotations (@Data, @Builder, etc.) to keep the class compact. Additional options cover package declaration, @JsonProperty for Jackson mapping, @TableField for MyBatis Plus, and configurable class name and indentation. Download a .java file directly — the entire conversion runs in your browser.

Input

JSON

Lombok

Code Style

Naming

1 rows, 7 columns
Output

Java Code

What is JSON to Java Converter?

Java's verbosity is most painful when writing model classes: private fields, getters, setters, constructors, all for a data shape defined by a JSON API response you did not design. This converter generates that boilerplate from the JSON itself. Paste a response sample and get a complete Java class with field declarations, accessor methods, and Jackson @JsonProperty annotations needed to deserialise the JSON with ObjectMapper. Choose between standard JavaBean style, Lombok @Data for annotation-driven boilerplate elimination, or Jackson-annotated output for APIs with non-Java-convention key names. Arrays become List<T>; nested objects become separate classes. The generated code is compatible with Spring Boot @RequestBody autowiring, Android Gson deserialiser, and any standard Jackson-based pipeline.

How to Use

  1. 1

    Paste Your JSON

    Paste a JSON object or array sample into the editor. For arrays, include multiple items to improve type inference accuracy across all array element fields.

  2. 2

    Configure Java Class Options

    Set the root class name, choose between standard POJO, Jackson-annotated, or Lombok @Data output style, and select whether to generate getters/setters and a no-arg constructor.

  3. 3

    Generate Java Classes

    Click "Generate Java". The tool produces a class per nested object, maps JSON types to Java types (String, Integer, Double, Boolean, List<T>), and adds @JsonProperty annotations when key names differ from Java conventions.

  4. 4

    Add to Your Java Project

    Copy the generated class(es) into your src/main/java directory. Add Jackson or Gson as a dependency if not already present, then use ObjectMapper.readValue(json, Root.class) to deserialise.

Common Use Cases

Spring Boot REST APIs

Generate Java POJO classes from API request or response JSON to use as @RequestBody and @ResponseBody types in Spring Boot controllers, with Jackson annotations for serialisation.

Android App Development

Convert JSON API responses into Java model classes for Android apps using Gson or Jackson, enabling type-safe data binding without manually writing every field declaration.

Hibernate Entity Scaffolding

Generate Java class definitions from a JSON data sample to bootstrap Hibernate entity classes. Add JPA annotations (@Entity, @Column) after generation to complete the ORM mapping.

Legacy Java System Integration

When integrating with older Java systems that expect typed POJOs rather than dynamic JSON maps, generate the required class structure from a sample JSON payload to maintain strict type boundaries.

Conversion Examples

JSON Object → Java Class

A JSON object generates a Java class with private fields and getters/setters.

Input JSON

{
  "id": 1,
  "name": "Alice",
  "email": "alice@example.com",
  "active": true
}

Output CSV

public class Root {
    private int id;
    private String name;
    private String email;
    private boolean active;

    public int getId() { return id; }
    public void setId(int id) { this.id = id; }
    public String getName() { return name; }
    public void setName(String name) { this.name = name; }
    // ... additional getters/setters
}

Nested JSON → Nested Java Classes

Nested objects generate separate Java classes with typed references.

Input JSON

{
  "order": {
    "id": 101,
    "customer": {"name": "Alice", "id": 1},
    "total": 149.99
  }
}

Output CSV

public class Customer {
    private int id;
    private String name;
    // getters/setters...
}

public class Order {
    private int id;
    private Customer customer;
    private double total;
    // getters/setters...
}

public class Root {
    private Order order;
    // getters/setters...
}

Frequently Asked Questions