JSON to Java Converter Online — Generate POJO Classes

Generate Java POJO classes from any JSON payload — private fields, public getters and setters, nested classes, and Jackson-compatible naming. 100% in your browser.

What is a JSON to Java converter?

A JSON to Java converter reads a JSON sample and emits typed Plain Old Java Objects (POJOs) that mirror the JSON shape — private fields, public getters and setters, nested classes, and the right primitive or wrapper types. The output drops straight into a Spring, Quarkus, Micronaut, or Android project and deserializes with Jackson, Gson, or Moshi without runtime reflection surprises.

Writing model classes by hand from a 200-field API payload wastes hours and is bug-prone — a single typo in a field name silently nulls out a value at runtime. OpenFormatter's converter walks the JSON tree once, generates idiomatic Java, and runs entirely in your browser so internal API responses never leave your machine.

How to generate Java POJOs from JSON — 4 steps

  1. Paste a real JSON response. Use a representative sample — the type inference quality depends on it. Booleans must be true/false (not 0/1), numbers must be unquoted.
  2. Click Convert. The tool emits a Root class plus one separate class per nested object, with private fields and public getters/setters.
  3. Copy and paste into your IDE. Each class is independent — split them into separate .java files in your com.example.model package.
  4. Deserialize. Root r = new ObjectMapper().readValue(json, Root.class); — that is all Jackson needs once the POJO has a no-arg constructor and setters.

JSON to Java type mapping

Sample JSON

{
  "id": 42,
  "name": "Ada Lovelace",
  "active": true,
  "score": 98.5,
  "address": { "city": "London" },
  "tags": ["admin", "engineer"]
}

Generated Java POJO

import java.util.List;

public class Root {
    private int id;
    private String name;
    private boolean active;
    private double score;
    private Address address;
    private List<String> tags;

    public int getId() { return id; }
    public void setId(int val) { this.id = val; }
    public String getName() { return name; }
    public void setName(String val) { this.name = val; }
    public boolean isActive() { return active; }
    public void setActive(boolean val) { this.active = val; }
    // ... etc
}

public class Address {
    private String city;
    public String getCity() { return city; }
    public void setCity(String val) { this.city = val; }
}

Idiomatic POJOs

Private fields, public getters/setters, no-arg constructors — exactly what Jackson, Gson, and Moshi expect for reflection-based deserialization.

Nested classes

Every nested JSON object becomes its own typed class so you can split files and see the full hierarchy at a glance.

Client-Side Only

JSON is parsed in JavaScript inside the browser. Internal API responses, tokens, or PII never reach a server.

Common use cases

  • check_circleGenerating Spring Boot @RestController request and response DTOs from a frontend JSON payload
  • check_circleBuilding Jackson-deserializable models for a third-party REST API (Stripe, Slack, GitHub)
  • check_circleProducing Android Retrofit response bodies from a JSON spec
  • check_circleGenerating Lombok @Data classes after copying — strip getters/setters and add @Data
  • check_circleModelling Kafka or RabbitMQ JSON event payloads as typed POJOs
  • check_circleBuilding Micronaut or Quarkus serverless function request/response classes
  • check_circleGenerating GraphQL response shapes when a tool like Apollo codegen is overkill
  • check_circleModelling configuration files (application.json) into typed @ConfigurationProperties

Why client-side generation matters

The JSON you paste often contains real customer data, OAuth tokens, signed URLs, or internal field names you do not want indexed by a third-party converter. OpenFormatter generates the Java entirely in JavaScript on your device — open the Network tab in DevTools and you will see zero requests when you click Convert. Safe for enterprise use, safe behind a corporate proxy, safe when the API contract is itself confidential.

Need other Java tooling?

Format Java source, parse JSON inside Java code, or generate types for other languages — all browser-side.

Frequently Asked Questions

Does it use Jackson or Gson annotations?

The generated classes are plain POJOs that work with both Jackson (the most common) and Gson out of the box because field names match the JSON keys via getter/setter convention. For JSON keys that are not valid Java identifiers, add @JsonProperty("original_key") (Jackson) or @SerializedName("original_key") (Gson) on the field — the generator preserves the JSON key in a comment so it is easy to copy.

Can I use Lombok @Data?

Yes. Replace the generated getters and setters with @Data above the class declaration. Lombok then generates them at compile time. For immutable models use @Value, and add @Builder for fluent construction. The generator emits the full boilerplate so the output runs without any annotation-processing setup.

Why are fields generated as int instead of Integer?

Primitive int is used when the JSON sample has a non-null integer. For nullable integer fields use the boxed Integer type — Jackson and Gson both deserialize JSON null into a null Integer, which would crash an int field.

How are JSON arrays mapped?

Arrays of objects become List<ClassName> using java.util.List. Arrays of strings become List<String>; arrays of mixed primitives become List<Object>. Make sure your build path imports java.util.List or replace with ArrayList<T> on declaration.

How are nested JSON objects modelled?

Each nested object becomes its own top-level public class so you can split them across files. The parent class references the nested type by its PascalCase name. The class names are derived from the JSON key (camelCase to PascalCase).

Is the JSON uploaded to your servers?

No. Conversion runs entirely in your browser via JavaScript. Open DevTools → Network and click Convert — no requests are made. Pasting JSON containing tokens or PII never leaves your machine.

How do I deserialize the generated classes with Jackson?

ObjectMapper mapper = new ObjectMapper(); Root root = mapper.readValue(jsonString, Root.class); — the generated POJO has a no-arg constructor (default) and public setters, which is everything Jackson requires.

How are JSON keys with dashes or reserved words handled?

A JSON key like "user-id" is converted to userId. Reserved Java words such as "class" or "package" are suffixed (classField). Annotate with @JsonProperty("user-id") to preserve the wire-format key during serialization.

JSON to Java Converter Online — Generate POJO Classes