JSON to Java class
Turn a JSON sample into Java classes, with nested types and generic lists inferred automatically.
JSON to Java class
Paste a JSON sample and this tool generates the Java classes needed to represent it, inferring field types, nested object types and generic list element types directly from the values you provide. It is built for backend developers who receive an API response or a config file and need a typed model to deserialize it into, without hand-writing every field.
Choose how fields are annotated: none, Jackson's @JsonProperty, or Gson's @SerializedName, each carrying the original JSON key so serialization still matches after a field is renamed to camelCase. Turn off getters and setters for a plain class with public fields, or replace them with Lombok's @Data or a Java record, where components take the place of fields and accessors. Wrapper types (Integer, Boolean, Double) can be forced everywhere instead of primitives; the tool always uses a wrapper where a value is genuinely optional, since a primitive can never hold null. A package declaration is added when supplied, and nested objects render as static nested classes in one file or as separate top-level classes.
When the same shape appears more than once — repeated objects in an array, or two sibling fields with identical structure — the tool reuses a single generated class instead of duplicating it. Fields observed with different shapes across an array are merged into one class, with fields absent from some elements marked optional. Numbers stay as int where they fit a 32-bit range and widen to long or double as needed; a JSON key that cannot be a Java identifier, such as an emoji, falls back to a safe generated name.
Everything runs locally in your browser — no JSON sample is ever uploaded or transmitted to a server. Copy the generated classes into your project, download them as a .txt file, or send the output back into the input to run another tool on it.