JSON Parser

JSON to Java Class Converter Online

Paste any JSON and get ready-to-use Java types in one click. Nested objects, arrays, optional fields and awkward key names are handled for you, and everything runs in your browser, so API responses and sample payloads are never uploaded.

How to convert JSON to Java

  1. Paste your JSON, or click Upload to load a file. Use a sample that includes every field, since the types are inferred from it.
  2. Set the Root class name if you want something other than Root.
  3. Review the output on the right and click Copy.

Example

JSON input

{
  "id": 1,
  "name": "Alice",
  "active": true,
  "score": 98.5,
  "tags": ["admin"],
  "address": { "city": "New York" }
}

Java output

import java.util.List;

public class Root {
    private Long id;
    private String name;
    private Boolean active;
    private Double score;
    private List<String> tags;
    private Address address;

    public Long getId() { return id; }
    public void setId(Long id) { this.id = id; }

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

    public Boolean getActive() { return active; }
    public void setActive(Boolean active) { this.active = active; }

    public Double getScore() { return score; }
    public void setScore(Double score) { this.score = score; }

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

    public Address getAddress() { return address; }
    public void setAddress(Address address) { this.address = address; }
}

class Address {
    private String city;

    public String getCity() { return city; }
    public void setCity(String city) { this.city = city; }
}

JSON to Java type mapping

JSONJava
stringString
whole numberLong
decimal numberDouble
booleanBoolean
arrayList<T>
objecta class
null / unknownObject

Naming and structure

Fields are camelCase with getters and setters. When the JSON key differs from the camelCase field name (for example first-name or user_id), the field gets @JsonProperty("original-key") so Jackson maps it back.

  • Nested objects become separate classes, named after their key (an orders array becomes an Order class).
  • Boxed types (Long, Double, Boolean) are used so fields can be null.
  • When an array contains objects, their fields are merged: a field missing from some items is treated as optional, and a field that is a whole number in one item and a decimal in another becomes a decimal.
  • The top-level JSON can be an object or an array of objects.

Using the generated types

ObjectMapper mapper = new ObjectMapper();
Root root = mapper.readValue(jsonString, Root.class);

Related tools

Describe the same data with the JSON Schema generator, get TypeScript interfaces, create a SQL table, fix broken input with JSON Repair, or compare payloads with JSON Diff.

Frequently asked questions

How do I convert JSON to a Java class?
Paste your JSON, set the root class name, and copy the generated Java. Each nested object becomes its own class, arrays become List<T>, and numbers map to Long or Double depending on whether they have a decimal part.
Does it add Jackson annotations?
Yes. When a JSON key is not a valid camelCase Java field name (for example first-name or user_id), the generated field gets a @JsonProperty("original-key") annotation so Jackson maps it back correctly.
How are optional and null fields handled?
All fields use boxed types (Long, Double, Boolean) so they can hold null. A field that is null in every sample has no inferable type and becomes Object; if it is null in only some array items, the type comes from the items that do have a value. Everything runs in your browser — your JSON is never uploaded to a server.
Handles JSON files up to 20MB smoothly