Back to Tools

JSON to Java Class Generator

Free online JSON to Java class tool - supports Jackson, Gson annotations and Lombok

Loading...

How to Convert JSON to Java Class

  1. 1

    Paste JSON

    Copy your JSON data and paste it into the input field on the left.

  2. 2

    Configure Options

    Choose annotation style (Jackson/Gson), enable Lombok, set class name and package.

  3. 3

    Copy Result

    The Java class appears instantly on the right. Click copy or download to use it in your project.

Features Overview

Free online JSON to Java POJO class generator. Automatically generate Java class code from JSON data with support for Jackson, Gson annotations and Lombok.

Tool Description

Free online JSON to Java POJO class generator. Automatically generates Java class code, supporting Jackson @JsonProperty and Gson @SerializedName annotations, Lombok @Data, nested objects and arrays. Customize class name, package name, and getter/setter. 100% browser-side processing, no data uploads.

Capabilities Checklist

  • Convert JSON to Java POJO classes instantly with real-time preview.
  • Support Jackson @JsonProperty and Gson @SerializedName annotations.
  • Generate Lombok @Data classes to reduce boilerplate code.
  • Customize class name, package name, access modifiers, and indentation.
  • Handle nested objects, arrays, and mixed types automatically.

Related Tools

Frequently Asked Questions

How do I convert JSON to a Java class?
Paste your JSON data into the input field. The tool will automatically generate a Java POJO class with proper field types, including String, int, double, boolean, nested objects, and List types. You can then copy or download the result.
What is a POJO in Java?
POJO stands for Plain Old Java Object. It is a simple Java class with private fields, getters, setters, and optionally toString/equals/hashCode methods. This tool generates POJO classes from JSON data automatically.
How do I add Jackson annotations?
Select 'Jackson' in the annotation style dropdown. The tool will add @JsonProperty annotations to fields where the JSON key differs from the Java field name (e.g., snake_case to camelCase), and include the necessary import statement.
How do I add Gson annotations?
Select 'Gson' in the annotation style dropdown. The tool will add @SerializedName annotations to fields where the JSON key differs from the Java field name, and include the com.google.gson.annotations.SerializedName import.
What does the Lombok option do?
Enabling Lombok adds @Data annotation to the class, which automatically generates getters, setters, toString, equals, and hashCode methods at compile time. This significantly reduces boilerplate code. You need the Lombok dependency in your project.
How are nested JSON objects handled?
Nested JSON objects are converted to public static inner classes. For example, {"address": {"city": "Beijing"}} generates an Address inner class with a city field. The nesting depth is unlimited.
How are JSON arrays handled?
JSON arrays are converted to List<T> types. The element type is inferred from the first non-null element. Object arrays generate inner classes. Empty arrays default to List<Object>. Mixed-type arrays fall back to List<Object>.
What is the difference between primitive and wrapper types?
By default, the tool uses primitive types (int, double, boolean). Enable 'Use wrapper types' to use Integer, Double, Boolean instead. Wrapper types are nullable and required for generic type parameters like List<Integer>.
Can I use the generated code with Spring Boot?
Yes. The tool provides a Spring Boot Controller snippet that shows how to use the generated class as a @RequestBody parameter. You can also add Jackson annotations for proper JSON deserialization.
Does this tool upload my data to a server?
No. All conversions happen entirely in your browser. Your JSON data is never sent to any server. This ensures complete privacy for your code and data. You can even use this tool while offline.