How does JSON become a Java class?
The converter infers Java field types from the sample, creates a root class, and adds separate named classes for nested objects.
Paste sample JSON and generate Java models locally in your browser.
Use an object or an array of objects for model inference.
Generated code will appear here.Generate Java POJOs or records from sample JSON with typed fields and named nested models. Arrays become List<T>, and an import is added when the inferred model uses a list.
POJO output can include no-argument and all-argument constructors plus getters and setters. Record output provides a compact immutable data carrier for projects using a compatible Java version.
An optional package declaration can be placed above the generated models. Package names are validated as dot-separated Java identifiers before generation.
Primitive numeric and boolean types are used for required non-null fields. When a sample shows a field as nullable or missing, wrapper types such as Integer, Double, and Boolean allow the generated model to represent that state.
Example JSON input:
{
"order_id": 101,
"customer": {
"display_name": "Ada"
},
"items": ["book", "pen"]
}Generated Java output:
import java.util.List;
public record RootModel(
int orderId,
RootModelCustomer customer,
List<String> items
) {}
public record RootModelCustomer(
String displayName
) {}The converter infers Java field types from the sample, creates a root class, and adds separate named classes for nested objects.
POJO output uses fields and can generate constructors, getters, and setters. Record output uses Java record components for a concise immutable data carrier.
Required non-null numbers use int or double. Nullable or optional numbers use wrapper types such as Integer or Double so null can be represented.
Nested JSON objects become additional named Java models referenced by the parent field. Arrays of nested objects use List with the generated model type.
Yes. POJO output can generate a getter and setter for every inferred field. Records do not use that option because their components already expose accessors.
Your JSON input, field names, root model name, and generated Java source stay in this browser. They are not sent to a backend, added to the URL, or saved in local storage or cookies.
Compare another language-specific converter that uses the same local JSON inference engine.