๐Ÿ”’ Runs in your browser โ€” nothing is uploadedโœ“ Free, no signup

JSON to Java Class Converter

Paste JSON to generate Java records, classes with getters and setters, or Lombok @Data classes โ€” with Jackson @JsonProperty annotations where key names need them.

Loading...

0 characters

Java

Loading...

When should you use the JSON to Java?

  • Mapping an API response in a Spring Boot application
  • Creating request and response DTOs
  • Modelling JSON config or test fixtures in Java

How to use the JSON to Java

  1. 1

    Paste JSON

    Paste a sample object or array.

  2. 2

    Choose the style

    Records (Java 16+), classes with getters and setters, or classes with Lombok's @Data.

  3. 3

    Name it

    Set the class name and, optionally, a package.

  4. 4

    Copy

    Copy the code. Put each public type in its own .java file.

Examples

A record with a renamed key

JSON

{ "id": 1, "zip-code": "N1", "tags": ["a"] }

Java

public record Root(
    long id,
    @JsonProperty("zip-code") String zipCode,
    List<String> tags
) {}

Common errors and how to fix them

Several public classes in one file
Java allows one public top-level type per file. Move each record or class into its own .java file.
Optional numbers are Long instead of long
Fields that can be missing or null use boxed types (Long, Double, Boolean) so they can hold null.
Related tools:ย JSON to Go ยท JSON to Python ยท JSON to TypeScript

More from JSON Tools

Free tools that run in your browser โ€” no signup, nothing uploaded.

JSON to Java FAQ

Jackson โ€” the default in Spring Boot. @JsonProperty is added whenever the Java field name differs from the JSON key.

Records (Java 16+) are concise and immutable โ€” ideal for DTOs. Use classes if you need setters or older Java versions.

Whole numbers become long and decimals double. Fields that can be missing or null use Long and Double so they can be null.

Reserved words and names starting with a digit are renamed (classValue, x2fa) and mapped back with @JsonProperty.

Arrays become List<T>. If the root of your JSON is an array, deserialize it as a List of the generated type.

No. Everything runs in your browser, so your JSON never leaves your device.