JSON to Java Class
Paste JSON and generate clean, ready-to-paste Java records, POJOs, or Lombok classes with nested models, typed fields, and serialization annotations.
Input JSON
Generated Java
Your generated Java classes will appear here.About JSON to Java Class
This free tool turns any JSON object or array into ready-to-use Java classes in one click. It inspects your JSON, infers the most specific type for every field, and generates strongly-typed models you can paste straight into a Spring Boot service, an Android app, or any Java project.
Pick the output that fits your codebase: modern Java records (Java 14+), classic POJOs with private fields plus getters and setters, or Lombok classes annotated with @Data. The generator chooses the right type for each value — Integer or Long depending on the number's size, Double for decimals, Boolean, and String — and builds nested classes for inner objects and List<T> types for arrays. Fields that are null or only present in some array items use boxed reference types so they can safely hold null.
JSON keys in snake_case are converted to camelCase field names, with a Jackson (@JsonProperty) or Gson (@SerializedName) annotation added so the original key still maps correctly during (de)serialization. ISO-8601 date strings can be mapped to java.time types such as OffsetDateTime or Instant. Everything runs entirely in your browser, so your JSON never leaves your device.
How to Use JSON to Java Class
- Paste a JSON object or array into the input box, or click Load Sample to try it.
- Set the root class name and package name for the generated file.
- Choose a class style — Record, POJO, or Lombok @Data.
- Select an annotation library (Jackson or Gson) and a date type, then toggle primitives if you prefer
int/boolean. - Copy the generated Java and paste it into your project.
public and nested classes are package-private, so they compile together in a single .java file. Split them into separate files (and make each public) if your project requires it.What it handles
- ✅ Records, POJOs & Lombok
- ✅ Nested classes
- ✅
List<T>for arrays - ✅
IntegervsLongdetection - ✅ Jackson & Gson annotations
- ✅
snake_case→camelCase
FAQ
Does this tool send my JSON to a server?
No. All parsing and code generation happens in your browser, so your JSON stays on your device.
What is the difference between Record, POJO, and Lombok output?
A record is a compact, immutable Java 14+ class. A POJO is a classic class with private fields plus getters and setters. Lombok uses a @Data annotation to generate the accessors at compile time, keeping the source short.
How are JSON keys like created_at handled?
They become camelCase fields (createdAt), and a name annotation such as @JsonProperty("created_at") is added so serialization still maps to the original key.
Does it support root-level JSON arrays?
Yes. A root array generates a class for the element shape plus a comment showing how to deserialize it as List<ClassName>.
Why does it use Integer instead of int?
Boxed types like Integer and Boolean can hold null, which matters for optional JSON fields. Enable Use primitives to emit int/boolean for non-null fields instead.
How does it choose between Integer and Long?
Whole numbers within the 32-bit range become Integer; larger values become Long. Decimals become Double.