JSON to Java Converter

Convert JSON to Java
classes online, free & instant

Paste your JSON and generate strongly-typed Java POJO classes in one click. Automatic type inference, nested class generation, and standard naming conventions. Runs entirely in your browser.

Open JSON to Java Converter

From JSON to type-safe Java in seconds

Paste your JSON Drop any JSON object into the input. Each key-value pair is analyzed to infer the correct Java type.
Typed field generation Strings become String, numbers become int or double, booleans become boolean, and arrays become List<T> with inferred element types.
Nested class support Nested JSON objects generate inner classes with their own typed fields, matching the full depth of your data.
Copy and use One-click copy sends the Java code to your clipboard. Drop it into your project and use with Jackson, Gson, or any serializer.

No account. No upload. No nonsense.

🔒

100% Private

Your JSON never leaves your device. There is no server receiving your data.

Instant Output

Conversion happens as you type. No round-trips to a backend, no latency.

Java-Ready Code

Generated POJOs follow standard Java naming conventions and work with all major JSON libraries.

Related JSON tools

JSON to CSV Convert JSON arrays to spreadsheet-ready CSV files instantly.
JSON to XML Convert JSON to well-formed XML with proper nesting and element mapping.
JSON Schema Validator Validate JSON against a JSON Schema with detailed error reporting.
JSON Formatter Pretty-print JSON with syntax highlighting and a collapsible tree view.

Common questions answered

Is the JSON to Java converter free?

Yes, completely free with no account or signup required. The converter runs entirely in your browser.

What Java types does the converter generate from JSON?

JSON strings map to String, numbers to int or double (based on whether they contain decimals), booleans to boolean, arrays to List<T>, and nested objects to inner classes with their own typed fields.

Does it generate getters and setters?

The converter generates clean POJO classes with private fields. You can easily add getters and setters or use Lombok annotations (@Data, @Getter, @Setter) in your project.

Can I use the generated classes with Jackson or Gson?

Yes. The generated POJOs follow standard Java naming conventions and work directly with Jackson, Gson, Moshi, and other JSON serialization libraries without modification.

Is my data sent to a server during conversion?

No. All conversion runs entirely in your browser using JavaScript. Your JSON is never uploaded or transmitted to any server.

Converting JSON to Java classes

Java uses Jackson or Gson for JSON serialization, requiring Java classes (POJOs) with matching fields. This tool generates complete class definitions with proper types (String, int, double, boolean), getter/setter methods, and @JsonProperty annotations for Jackson compatibility.

The converter follows Java conventions: PascalCase class names, camelCase fields with private access, JavaBean getter/setter pattern, and List<T> for arrays. The output includes Jackson imports. For modern Java, it can produce Java 16+ record types, which are more concise than traditional POJOs.

Convert JSON to Java classes
Input
{
  "name": "Alice",
  "age": 30,
  "roles": ["admin"],
  "address": {
    "city": "Portland"
  }
}
Output
public class Root {
    private String name;
    private int age;
    private List<String> roles;
    private Address address;

    // getters and setters
    public String getName() {
        return name;
    }
    // ... (generated for all fields)
}

Get the most out of this tool

Ready to convert your JSON to Java?

Free forever. No signup. Works offline.

Convert JSON to Java now

Java POJO generation from JSON explained

Java's strong typing means you must define explicit classes to deserialize JSON into typed objects. The two most widely used Java JSON libraries are Jackson (by FasterXML, used by Spring Boot by default) and Gson (by Google, common in Android development). Both support deserializing JSON into Plain Old Java Objects (POJOs) — regular Java classes with fields and getter/setter methods. This converter generates Java POJOs with Jackson annotations, which is the standard for Spring Boot applications.

The converter maps JSON types to Java types with specific conventions. JSON strings become String. JSON integers become int (primitive) or Integer (boxed) — the boxed form is preferred when null is possible. JSON floating-point numbers become double or Double. JSON booleans become boolean or Boolean. JSON null maps to null for boxed types. Arrays become List<T> (from java.util.List), and nested objects become separate Java class files — each nested object gets its own public class.

Jackson annotations handle the naming mismatch between JSON conventions and Java conventions. JSON APIs typically use camelCase or snake_case keys. Java classes use camelCase fields by default, which maps well to camelCase JSON. For snake_case JSON keys, the @JsonProperty("field_name") annotation maps the snake_case JSON key to a camelCase Java field name. Alternatively, configuring ObjectMapper with MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES handles case differences globally.

Spring Boot auto-configures Jackson for JSON serialization and deserialization in REST controllers. @RestController methods that return Java objects are automatically serialized to JSON. @RequestBody parameters are automatically deserialized from the request JSON. The generated Java classes work directly as Spring MVC request and response types. Spring Boot also provides @JsonCreator and @JsonProperty on constructors for immutable deserialization.

Java 14+ records provide a concise alternative to traditional POJOs for immutable data models. A Java record automatically generates a canonical constructor, getters, equals(), hashCode(), and toString(). Jackson 2.12+ supports records natively. For new Spring Boot 3+ projects (Java 17+), records are an excellent choice for JSON DTOs — they are more concise than classes with boilerplate getters and setters, reducing the code that needs to be written and maintained.

Lombok is a popular Java annotation processor that reduces boilerplate in POJOs. @Data generates getters, setters, equals(), hashCode(), and toString(). @Builder generates a builder pattern. @NoArgsConstructor and @AllArgsConstructor generate constructors. Many developers combine Lombok annotations with Jackson annotations for clean, readable POJO code. The converter generates standard POJOs that you can optionally annotate with Lombok for brevity.

When developers use this tool

Spring Boot REST API development Generate Java POJOs from your API's JSON examples to use as @RequestBody types and response objects in Spring MVC controllers. Spring Boot's Jackson integration deserializes them automatically.
Microservice payload modeling Define the message payloads exchanged between microservices by generating Java classes from shared JSON schemas. Keep these classes in a shared library referenced by all services to ensure consistency.
Third-party API integration When consuming a third-party REST API (payment providers, shipping APIs, social platforms), generate Java classes from their JSON documentation to use with RestTemplate or WebClient for typed responses.
Legacy Java modernization Modernize old Java 8 code that uses Map<String, Object> for JSON to strongly typed POJOs. Generate the class from a real data sample to capture the exact field structure used in production.

Additional frequently asked questions

Should I use Jackson or Gson for JSON in Java?

For Spring Boot projects, use Jackson — it is the default and deeply integrated with the framework. For Android apps, Gson is lighter and historically more popular, though kotlinx.serialization is now the preferred choice for Android with Kotlin. For non-Spring Java applications, Jackson is more feature-rich and actively maintained.

How do I handle JSON fields whose names are Java reserved keywords?

Use the @JsonProperty annotation: @JsonProperty("class") private String className. Choose a legal Java identifier for the field name and map it to the JSON key with the annotation. Common conflicts include "class", "interface", "static", "int", and "new".

Can I deserialize JSON into an immutable Java class?

Yes, using Jackson's @JsonCreator on a constructor with @JsonProperty-annotated parameters. Jackson calls the annotated constructor with the deserialized values, building the immutable object without needing setters. Java records (Java 14+) provide this pattern with minimal boilerplate and full Jackson 2.12+ support.

How do I handle polymorphic JSON (different shapes for the same field)?

Jackson handles polymorphism with @JsonTypeInfo and @JsonSubTypes annotations. Mark the base class with these annotations, specifying a discriminator field (e.g., "type") and the subtype mappings. Jackson then deserializes each JSON object to the appropriate subclass based on the discriminator value.