JSON to Java POJO Generator
Paste a JSON sample and get clean Java classes instantly. Nested objects become their own classes, arrays become typed List fields, and Jackson @JsonProperty annotations keep the original keys. Switch between getters and setters, plain public fields, or Java records, and rename the root class.
How to convert JSON to Java
- Paste a JSON object into the input box.
- Pick an output style: getters and setters, public fields, or a record.
- Optionally rename the root class and toggle Jackson annotations.
- Copy the generated Java or download it as a .java file.
Examples
Flat object
{"name":"Ada","age":36,"active":true}public class Root {
@JsonProperty("name")
private String name;
...
}Nested object and array
{"user":{"id":1},"tags":["a","b"]}class User {
private Long id;
...
}
public class Root {
private User user;
private List<String> tags;
}Frequently asked questions
What does this tool do?
It reads a JSON sample and generates matching Java types, inferring the type of every field so you can drop the classes straight into your project. Use it to scaffold data transfer objects for an API response or config file.
How are JSON types mapped to Java?
Strings become String, whole numbers become Long, decimals become Double, booleans become Boolean, and null becomes Object. Wrapper types are used instead of primitives so a missing or null value is representable. Arrays become List of the element type, and nested objects become their own classes.
Can I generate getters and setters, plain fields, or records?
Yes. Choose getters and setters for a classic POJO, public fields for a lightweight container, or a Java 16 record for an immutable value type. The same type inference is used for every style.
What are the Jackson annotations for?
When enabled, each field gets a @JsonProperty annotation with the exact original JSON key. That lets Jackson deserialize keys that are not valid Java identifiers, such as first-name or created_at, into clean camelCase fields. Turn annotations off if you do not use Jackson.
Why is only one class public?
A single Java file can contain only one public top-level type, so the root class is public and every generated dependency is package-private. The whole result therefore compiles as one file, named after the root class.
How are keys that are not valid Java names handled?
Keys are converted to camelCase fields and PascalCase class names. Keys that start with a digit or clash with a Java keyword like class or new are prefixed with an underscore, while the @JsonProperty annotation preserves the real key.
Is my JSON sent to a server?
No. Parsing and code generation run entirely in your browser, so your data never leaves your machine.
Why did I get an error instead of classes?
The tool needs valid JSON with an object at the top level. Invalid syntax or a top-level array, string or number returns an error message instead of Java code.
Related tools
JSON to TypeScript
Generate TypeScript interfaces from a JSON sample. Infers nested objects, arrays and union types, then copy or download the .ts file. Runs in your browser.
JSON to Go
Generate Go structs from a JSON sample. Infers types, nested structs and slices, adds json tags, then copy or download the .go file. Runs in your browser.
JSON to Kotlin
Convert JSON to Kotlin data classes online. Paste JSON and get typed data class declarations with inferred Int, Double, List and nested types. In browser.
JSON Formatter
Format, validate and minify JSON online. Pretty-print with custom indentation, sort keys and catch syntax errors. Runs in your browser.
.env to JSON
Convert a .env file to JSON, or JSON back to .env. Parses KEY=value lines, comments, quotes and export. Runs entirely in your browser.
ASCII Table
Full ASCII table for all 128 codes with decimal, hex, octal and binary values, character names and descriptions. Search by code, hex or character.