JSON to Java Converter
Generate Java POJO classes from a JSON sample directly in your browser.
This tool runs entirely in your browser. Your files are never uploaded to a server.
import java.util.List;
public class Root {
private String name;
private Integer age;
private Boolean active;
private List<String> tags;
private Address address;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public Boolean getActive() {
return active;
}
public void setActive(Boolean active) {
this.active = active;
}
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;
}
}
public class Address {
private String street;
private String zip;
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public String getZip() {
return zip;
}
public void setZip(String zip) {
this.zip = zip;
}
}What this converter does
Reads a JSON value and generates matching Java classes: one plain class (POJO) per object shape found in the sample, each with private fields and public getter/setter methods.
How to use it
Paste a JSON object, array or primitive value into the editor. A `Root` class appears immediately, along with one additional class for every nested object shape; a non-object root is wrapped in a `Root` class with a single `value` field.
Example
An object with a `name` string and a nested `address` object produces a `Root` class with a private `String name` field plus `getName`/`setName` methods, and a separate `Address` class for the nested shape.
Type mapping
Strings become `String`, whole numbers become `Integer`, decimal numbers become `Double`, booleans become `Boolean`, and arrays become `List<ElementType>` (with the needed `java.util.List` import added automatically). Values sampled as `null` are typed as `Object`.
Nested objects and lists
Each nested object gets its own class, generated from its key. Class order in the output doesn't matter in Java, since classes in the same file can reference each other regardless of declaration order.
Limitations
The generated classes describe only the one JSON sample provided, use boxed types throughout for simplicity (so no primitive int/double/boolean fields), and don't include a constructor, equals/hashCode, toString, or any JSON (de)serialization annotations — add a library like Jackson or Gson if you need that.
Privacy
Parsing and code generation both run locally in your browser. The JSON you paste and the Java you generate are never uploaded.
Frequently Asked Questions
- Do the generated classes include JSON library annotations?
- No — they're plain POJOs with private fields and getters/setters; pair them with a library like Jackson or Gson for actual JSON (de)serialization.
- Why are the fields Integer/Double instead of int/double?
- Boxed types keep the generated code simple and consistent even for fields that could be null, at the cost of a small amount of autoboxing overhead.
- Is my JSON sent to a server?
- No — parsing and Java generation both happen locally in your browser.