>_devtools

JSON to Java Class Converter

Generate Java classes from a JSON sample, with package, collection type, and Lombok options.

What this does

Generates plain Java classes (POJOs) with private fields and getters and setters from a JSON sample. Every nested object becomes its own class, and the output lists each class under a// ClassName.java marker so you can split it into files.

Example

Input

{
  "id": 42,
  "name": "Ada",
  "verified": true,
  "tags": [
    "admin",
    "dev"
  ],
  "orders": [
    {
      "sku": "A1",
      "qty": 2
    },
    {
      "sku": "B2",
      "qty": 1,
      "note": "gift"
    }
  ]
}

Output with default options

// Root.java

package com.example;

import java.util.List;

public class Root {
    private long id;
    private String name;
    private boolean verified;
    private List<String> tags;
    private List<Order> orders;

    public long getID() { return id; }
    public void setID(long value) { this.id = value; }

    public String getName() { return name; }
    public void setName(String value) { this.name = value; }

    public boolean getVerified() { return verified; }
    public void setVerified(boolean value) { this.verified = value; }

    public List<String> getTags() { return tags; }
    public void setTags(List<String> value) { this.tags = value; }

    public List<Order> getOrders() { return orders; }
    public void setOrders(List<Order> value) { this.orders = value; }
}

// Order.java

package com.example;

public class Order {
    private String sku;
    private long qty;
    private String note;

    public String getSku() { return sku; }
    public void setSku(String value) { this.sku = value; }

    public long getQty() { return qty; }
    public void setQty(long value) { this.qty = value; }

    public String getNote() { return note; }
    public void setNote(String value) { this.note = value; }
}

How values are mapped

  • Whole numbers become long, other numbers double, strings String, booleans boolean.
  • Arrays become List<T> (or T[] if you choose arrays).
  • ISO 8601 timestamps become OffsetDateTime, or Date with the legacy option; UUID strings become UUID.
  • Values that are always null become Object; mixed-type arrays get a small holder class with one field per type.

Options

Set the package and root class name, pick lists or arrays, and choosejava.time or java.util.Date. Lombok annotationsreplaces the getters and setters with a @lombok.Data annotation. WithTypes only turned off, the classes get Jackson @JsonPropertyannotations and a Converter class with fromJsonString andtoJsonString methods.

Things to know

Property names are converted to Java conventions (x-y becomes xY); with Jackson annotations on, the original key is preserved. Include several representative objects in an array so the generated types reflect every field your data can contain.

Privacy

Generation runs in a Web Worker in your browser. The JSON is never uploaded.