json-to-go.input
json-to-go.output
public class Profile {
@JsonProperty("age")
private int age;
@JsonProperty("city")
private String city;
public int getAge() { return age; }
public void setAge(int age) { this.age = age; }
public String getCity() { return city; }
public void setCity(String city) { this.city = city; }
}
public static class RootObject {
@JsonProperty("id")
private int id;
@JsonProperty("name")
private String name;
@JsonProperty("active")
private boolean active;
@JsonProperty("score")
private double score;
@JsonProperty("tags")
private List<String> tags;
@JsonProperty("profile")
private Profile profile;
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 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 Profile getProfile() { return profile; }
public void setProfile(Profile profile) { this.profile = profile; }
}About JSON to Java
Java is strongly typed, so consuming JSON APIs means writing many POJO/DTO classes by hand - tedious and error-prone. This tool parses your sample JSON locally and generates complete Java classes: field names become camelCase, nested objects become inner classes, arrays infer to List<T> generics, with optional getters/setters and @JsonProperty annotations. Nothing is uploaded.
How to Use
- Open the JSON to Java tool page
- Enter or paste your data into the input area
- View the real-time results and use the copy button to get the output
Use Cases
- Consume REST APIs — Paste API response JSON and get ready-to-use Java DTOs instantly.
- Generate ORM entities — Create entity classes from database JSON samples for MyBatis/JPA mapping.
- Jackson/Gson modeling — Auto-add @JsonProperty annotations for Jackson serialization compatibility.
- Android/Kotlin interop — Generate Java classes callable from Kotlin with type safety.
FAQ
Which Java versions are supported?
Generated code is compatible with Java 8+, using standard List<T> generics and annotation syntax.
How are null values handled?
null infers to Object type. Use a non-null sample for more precise types.
Can it generate BigDecimal?
Enable the BigDecimal option and all number fields use java.math.BigDecimal.
How are nested objects handled?
Each nested object becomes a static inner class - clean and reusable.
Comments
💬 Comments are stored locally in your browser. Configure Giscus for cloud-based comments.