How to Convert JSON to Java POJOs (Classes, Constructors & Getters/Setters)

Multi-Toolkit Team7 min read
JavaWeb DevelopmentDeveloper Tools
TL;DR: Paste JSON into a JSON to Java generator and get complete POJOs — fields, a no-arg and all-args constructor, and getters/setters, with nested objects as their own classes and arrays typed as List<T>. No boilerplate, no install.

Mapping a JSON API to Java means POJOs: a class per object, typed fields, and accessors for frameworks like Jackson or Gson. Typing them by hand is slow and error-prone — generate them instead.

From JSON to POJOs in 3 steps

  1. Paste a JSON object or API response into the converter.
  2. Name the root class — nested objects get their own classes automatically.
  3. Copy the classes or download a .java file.

A real example

{ "id": 1, "name": "Jane", "tags": ["a", "b"] }

becomes a complete POJO:

import java.util.List;

public class Root {
    private int id;
    private String name;
    private List<String> tags;

    public Root() {}

    public Root(int id, String name, List<String> tags) {
        this.id = id;
        this.name = name;
        this.tags = tags;
    }

    public int getId() { return id; }
    public void setId(int id) { this.id = id; }
    public String getName() { return name; }
    public void setName(String name) { this.name = name; }
    public List<String> getTags() { return tags; }
    public void setTags(List<String> tags) { this.tags = tags; }
}

Types and generics

Numbers map to int or double, booleans to boolean, strings to String. Arrays become List<T> with the element type boxedList<Integer>, not the invalid List<int>, since Java generics can't hold primitives. Nested objects become their own classes, referenced by type.

All fields, merged from arrays

Paste an array of objects and the generator merges every field seen across the records into one class — so a key that appears only in later items isn't dropped. That makes the POJO safe to deserialize the whole response, not just the first record.

Tips

  • Add Jackson/Gson annotations as needed — the generated fields map 1:1 to JSON keys.
  • Name the root after the entity (User, Order).
  • Validate first with the JSON Validator if parsing fails.

FAQ

Does it generate constructors? Yes — a no-arg constructor and an all-args constructor, plus getters and setters.

Is my data uploaded? No — conversion runs entirely in your browser.

Need TypeScript or Python instead? See JSON to TypeScript and JSON to Python.

Convert JSON to Java free →

Related free tools: JSON to TypeScript · JSON to Python · All JSON Tools


← Back to all articles