JSON to Java Class Converter
Turn a JSON sample into a Java class in your browser. Optional and nullable fields are kept apart, and nothing is uploaded.
What the JSON to Java generator does
Each object becomes a class whose fields carry @JsonProperty with the original key, so Jackson reads and writes the same names. Every numeric field is a boxed type — Long, Double, Boolean — because Java generics cannot take a primitive: List does not compile, and one rule for every position is easier to trust than a check that depends on nesting depth. Each class is shown in its own file block, since Java allows one public class per file.
How to use it
JSON to Java Class Converter: paste the JSON into the box above, set Root type name (default "Root"), and press Run to get the Java class below.
Worked example
Input:
{
"orderId": "A-1001",
"total": 129.99,
"currency": "EUR",
"paid": false,
"customer": {
"email": "ada@example.com"
},
"lines": [
{
"sku": "X1",
"qty": 2
},
{
"sku": "X2",
"qty": 1,
"discount": 0
}
]
}
Output:
// Generated from a JSON sample in the browser by AllTools — nothing was uploaded.
// Rename and adjust to taste; the shape is inferred from one example, not a schema.
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
// Root.java
public class Root {
@JsonProperty("orderId")
public String orderId;
@JsonProperty("total")
public Double total;
@JsonProperty("currency")
public String currency;
@JsonProperty("paid")
public Boolean paid;
@JsonProperty("customer")
public Customer customer;
@JsonProperty("lines")
public List<Line> lines;
}
// Customer.java
public class Customer {
@JsonProperty("email")
public String email;
}
// Line.java
public class Line {
@JsonProperty("sku")
public String sku;
@JsonProperty("qty")
public Long qty;
@JsonProperty("discount")
public Long discount;
}
Why it runs in your browser
The conversion happens on this page with JavaScript. Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere. The page reads JSON and returns Java class; reloading the page discards both.
Each object becomes a class whose fields carry @JsonProperty with the original key, so Jackson reads and writes the same names. Every numeric field is a boxed type — Long, Double, Boolean — because Java generics cannot take a primitive: List<long> does not compile, and one rule for every position is easier to trust than a check that depends on nesting depth. Each class is shown in its own file block, since Java allows one public class per file.
Turn a JSON sample into a Java class in your browser. Optional and nullable fields are kept apart, and nothing is uploaded.
How to use it
JSON to Java Class Converter: paste the JSON into the box above, set Root type name (default "Root"), and press Run to get the Java class below.
Why it runs in your browser
The conversion happens on this page with JavaScript. Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere. The page reads JSON and returns Java class; reloading the page discards both.
What to Expect
Best for
- Converting JSON to Java class when the data is already on screen.
What this tool keeps
- Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere.
Sample input
{ "orderId": "A-1001", "total": 129.99, "currency": "EUR", "paid": false, "customer": { "email": "ada@example.com" }, "lines": [ { "sku": "X1", "qty": 2 }, { "sku": "X2", "qty": 1, "discount": 0 } ] }
Sample output
// Generated from a JSON sample in the browser by AllTools — nothing was uploaded. // Rename and adjust to taste; the shape is inferred from one example, not a schema. import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; // Root.java public class Root { @JsonProperty("orderId") public String orderId; @JsonProperty("total") public Double total; @JsonProperty("currency") public String currency; @JsonProperty("paid") public Boolean paid; @JsonProperty("customer") public Customer customer; @JsonProperty("lines") public List<Line> lines; } // Customer.java public class Customer { @JsonProperty("email") public String email; } // Line.java public class Line { @JsonProperty("sku") public String sku; @JsonProperty("qty") public Long qty; @JsonProperty("discount") public Long discount; }
Frequently asked questions
How do I use the json to java class converter?
JSON to Java Class Converter: paste the JSON into the box above, set Root type name (default "Root"), and press Run to get the Java class below.
Is my input uploaded?
No. The text is parsed on this page with JavaScript and is never posted to a server.
Is there a size limit?
Yes: 5 MB per run. Larger input is refused with a message rather than freezing the tab.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.