JSON to Java Class Generator
Paste JSON and instantly generate Java POJO classes with getters, setters, and proper type mapping
Paste any JSON payload and get back typed Java POJO classes — fields, getters, setters, nested objects, arrays, all mapped automatically. Supports Lombok @Data, wrapper types, and custom package names. And everything runs in your browser. Nothing gets uploaded.
How It Works
The converter parses your JSON, walks through every key-value pair, and figures out the Java type for each one. Strings become String, whole numbers become int (or long if they exceed Integer range), decimals become double. Nested objects get their own classes with PascalCase names derived from the JSON key. Arrays turn into List<T> with the element type inferred from the first item.
Examples
Simple User Profile
A basic API response with strings, numbers, and a boolean.
{
"name": "Alice Chen",
"age": 29,
"email": "[email protected]",
"active": true
}
public class Root {
private String name;
private int age;
private String email;
private boolean active;
// + getters/setters
}
Nested Order with Address
When your JSON has objects inside objects, the tool generates a separate class for each one.
{
"order_id": 4521,
"total": 89.99,
"shipping_address": {
"street": "742 Evergreen Terrace",
"city": "Springfield",
"zip": "62704"
}
}
public class Order {
private int orderId;
private double total;
private ShippingAddress shippingAddress;
}
public class ShippingAddress {
private String street;
private String city;
private String zip;
}
Array of Products with Lombok
An API returns a list of products. Enable Lombok to skip all the getter/setter boilerplate.
{
"products": [
{
"sku": "BK-1042",
"title": "Clean Code",
"price": 34.50,
"in_stock": true
}
],
"page": 1,
"total_pages": 12
}
import java.util.List;
import lombok.Data;
@Data
public class Root {
private List<Product> products;
private int page;
private int totalPages;
}
@Data
public class Product {
private String sku;
private String title;
private double price;
private boolean inStock;
}
Who Uses This
Turning API responses into DTOs and request models without hand-typing every field.
Learning how JSON maps to Java types for assignments and exam prep.
Generating model classes for Retrofit or Gson from real API payloads.
Creating typed test fixtures from JSON test data files.
Common Mistakes
Trailing commas, single quotes instead of double quotes, or unquoted keys will all fail. Run your JSON through a validator first if you copied it from logs or a console.
The default is "Root". If you don't change it, you'll end up renaming every file later. Set it to something like "UserResponse" or "OrderPayload" before generating.
Wrapper types (Integer, Double, Boolean) are only necessary when a field can be null in your JSON. Primitive types are faster and use less memory. Stick with primitives unless your data actually contains nulls.
Technical Details
- Processing: 100% client-side JavaScript
- Browser Support: Chrome, Firefox, Safari, Edge
- Type Mapping: String, int/Integer, long/Long, double/Double, boolean/Boolean, List<T>, Object
- Naming Convention: camelCase fields, PascalCase classes
- Options: Package name, Lombok @Data, getters/setters, wrapper types
Frequently Asked Questions
How do I convert JSON to a Java class?
Paste your JSON into the input box, pick a class name, and hit Generate. The tool parses every key, figures out the Java type, and builds a full POJO with fields, a constructor, and getters/setters. It takes about two seconds.
Does this tool support nested JSON objects?
Yes. Every nested object becomes its own Java class. A key like "billing_address" generates a BillingAddress class, and the parent class gets a field of that type. It works for any nesting depth.
What is a POJO in Java?
POJO stands for Plain Old Java Object. It is a regular Java class with private fields and public getters and setters — no frameworks, no special annotations required. POJOs are what most serialization libraries like Jackson and Gson expect when mapping JSON to Java objects.
Can I generate Lombok classes from JSON?
Absolutely. Toggle the Lombok option and each class gets an @Data annotation instead of manually written getters and setters. You will need Lombok as a dependency in your project's build file (Maven or Gradle).
Is my JSON data safe when using this converter?
Completely. The conversion runs entirely in your browser using JavaScript. Nothing gets sent to a server. You can disconnect your internet and the tool still works — that's how you know it is truly client-side.