JSON to Java Class

Generate Java POJO class definitions from JSON data — with getters, setters, and constructors

  1. Home
  2. /
  3. JSON to Java Class

Options

Generated Java Code

import lombok.Data;

@Data
public class User {
    private int id;
    private String name;
    private String email;
}

Classes

0

Fields

0

Style

-

Nesting

0

What Is a Java POJO?

A POJO (Plain Old Java Object) is a simple Java class with private fields and public getters/setters. It's the foundation for data transfer objects, entity classes, and models in Java applications. With Lombok annotations, you can eliminate boilerplate code.

How to Use

  1. Paste JSON — Enter valid JSON data.
  2. Set class & package names — Customize the output.
  3. Choose style — Lombok @Data or traditional getters/setters.
  4. Copy or download — Save as .java file.

Frequently Asked Questions

What Java versions are supported by the generated code?

The generated POJO classes use standard Java syntax compatible with Java 8 and above. With Lombok enabled, you need Lombok 1.18+ and Java 8+. Without Lombok, the code uses standard getter/setter conventions that work with any Java version.

Should I use Lombok or traditional getters and setters?

Lombok reduces boilerplate code significantly with annotations like @Data, @Getter, and @Setter. It is widely used in modern Java projects. Choose traditional getters/setters if you cannot use Lombok in your project or prefer explicit method definitions.

How are nested objects handled?

Nested JSON objects are generated as inner static classes within the main class. Each nested class follows the same pattern with private fields, getters, setters, and Lombok annotations based on your chosen options.

Can I customize the package name?

Yes. Enter a custom package name in the Package input field. The generated code includes the package declaration at the top of the file. If left empty, no package declaration is generated.

Does the tool support JSON arrays at the root level?

Yes. If your JSON is an array of objects at the root level, the tool generates the class definition based on the first object in the array. All fields across all array elements are considered for generating the complete class.

Last updated: 9 Jul 2026