Boneyard Tools

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

  1. Paste a JSON object into the input box.
  2. Pick an output style: getters and setters, public fields, or a record.
  3. Optionally rename the root class and toggle Jackson annotations.
  4. 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