JSON to POJO: Plain Java Classes, No Annotations
Get JavaBean-style classes you can drop into any project, whatever JSON library it uses, with field types taken from your real data.
Paste or upload your JSON
Use a real sample of your JSON, such as an API response or a saved file. A field that never appears in the sample can't appear in the classes either, so a fuller sample gives better POJOs.
Example input
{
"orderId": 1001,
"customer": {
"firstName": "Maria",
"email": "[email protected]"
},
"items": [
{ "sku": "A1", "qty": 2, "price": 14.50 },
{ "sku": "B2", "qty": 1, "price": 3, "note": "gift" }
],
"trackingId": 8901240544102066246
}Check the field types and names
There are no settings to pick. The classes follow your data and the usual JavaBeans naming, so a quick look at the types tells you whether the sample covered everything.
Read the generated POJOs
Everything lands in one file. Nested objects become public static classes inside Root, so the result compiles as a single Root.java.
Output for the example above (first part)
// Save as Root.java. Plain Java: no annotations and no libraries, so it compiles with
// nothing but the JDK (Java 8 or later).
// Fill it with any JSON library, for example Gson:
// Root data = new Gson().fromJson(json, Root.class);
import java.util.List;
public class Root {
private Integer orderId;
private Customer customer;
private List<Item> items;
private Long trackingId;
// ... constructor, getters, setters, toString and the Customer and Item classes followCopy or download Root.java
Add a package line if your project uses packages, then fill the objects with Gson, Jackson or your own code.
What is a POJO?
A POJO, or Plain Old Java Object, is an ordinary class that doesn't extend a framework class or depend on a library: just fields, getters and setters. That makes it easy to share between projects, test, and reuse with whatever JSON or database library you pick later.
The price of no annotations is that the class can't say which JSON key belongs to which field. If your keys are not plain camelCase, or you want the mapping written into the code, the JSON to Java page generates the same classes with Jackson annotations. For XML input there is XML to POJO, and the JSON Formatter tidies the JSON first.
Frequently Asked Questions
What exactly is in a generated POJO?
Private fields, a public no-argument constructor, a getter and a setter for every field, and a toString method. There are no annotations and no imports beyond java.util.List and java.math when a field needs them, so the file compiles with nothing but the JDK, on Java 8 or later.
How do I read my JSON into these classes?
The classes do not parse JSON themselves; a library fills them. With Gson it is one line: new Gson().fromJson(json, Root.class). If the JSON is a list, the comment at the top of the file shows the TypeToken call for List<Root>. Jackson also works when the keys are ordinary camelCase names, because it matches the setter names.
What happens to keys that are not valid Java names?
They are renamed and the field gets a comment with the original key, for example private Integer orderId; // JSON key "order_id". Plain POJOs have no annotations, so a library will not match a renamed field on its own. For snake_case keys you can tell it the rule once: Gson's FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES or Jackson's PropertyNamingStrategies.SNAKE_CASE. For keys like "first-name" or "2nd" you need an annotation on the field, and the JSON to Java page writes those Jackson annotations for you.
How does it choose between Integer, Long and Double?
It looks at how each number is written in your JSON, across every item of a list. Whole numbers that fit in 32 bits become Integer, bigger ones become Long (an ID like 8901240544102066246 keeps every digit), and anything past 64 bits becomes BigInteger. A number written with a decimal point or exponent, such as 14.50 or 1e3, becomes Double, or BigDecimal if the same field also holds whole numbers too long for a Double. Quoted values like "00501" stay String, so leading zeros survive.
What if the items of a list have different fields?
All items are merged into one class, so a field that only appears in some of them is still generated and simply stays null when it is missing. A field that is a whole number in one item and a decimal in another becomes Double; one that holds, say, a number in one item and text in the next becomes Object.
Is my JSON sent anywhere?
No. The classes are generated in your browser as you type, and nothing you paste or upload is sent to our server or kept after you leave the page.
Related Tools
JSON to C
Convert JSON data to C structs with parsing functions and memory management
JSON to C++
Convert JSON data to modern C++ classes with STL containers and smart pointers
JSON to C#
Convert JSON data to C# classes with properties and attributes
JSON to Python
Convert JSON data to Python dataclasses with type hints
JSON to Java
Convert JSON data to Java classes with getters, setters, and annotations
JSON to TypeScript
Convert JSON data to TypeScript interfaces and types