Json2POJOJson2POJO

Free Online JSON to POJO Converter

Convert JSON to Java POJO classes instantly. Generate production-ready Java and Kotlin code with Jackson, Gson, Moshi, Lombok, and ObjectMapper support.

Instant & Offline-Ready
No Server Logs (Client-Side)
100% Client-Side Secure • Data Never Leaves Your Browser
JSON Input
Loading...
Java Output
Loading...

How to Convert JSON to POJO Online

Converting JSON to Java POJO classes is simple with our free online tool. Follow these three steps:

1

Paste Your JSON

Copy your API response, sample JSON, or JSON schema into the input editor.

2

Select Options

Choose Jackson, Gson, or Moshi. Enable Lombok or generate Kotlin data classes.

3

Copy Generated Code

Get production-ready Java or Kotlin classes. Paste directly into your IDE.

Using ObjectMapper with Generated POJOs

Once you've generated your POJO class, use Jackson's ObjectMapper to convert between JSON strings and Java objects:

// Parse JSON string to POJO
ObjectMapper mapper = new ObjectMapper();
User user = mapper.readValue(jsonString, User.class);
// Convert POJO back to JSON
String json = mapper.writeValueAsString(user);

Pro tip: Add @JsonIgnoreProperties(ignoreUnknown = true) to handle APIs that may add new fields without breaking your code.

JSON to POJO Example

Here's a practical example showing how our converter transforms JSON into a Java class with Jackson annotations:

INPUT: JSON

{
  "id": 12345,
  "userName": "john_doe",
  "email": "john@example.com",
  "isActive": true
}

OUTPUT: Java POJO

@JsonIgnoreProperties(...)
public class User {
  @JsonProperty("id")
  private int id;
  // getters, setters...
}

What is a POJO Generator?

A POJO Generator is a developer tool that automates the creation of Plain Old Java Objects from raw JSON data. Instead of manually writing getter and setter methods, developers use this online converter to instantly create strongly-typed Java classes compatible with libraries like Jackson, Gson, and Moshi.

Why use a Generator?

Manual mapping is error-prone. One typo in a field name like userID vs userId causes runtime failures. Our tool guarantees 100% field compliance.

Data Privacy

Unlike server-side converters, this tool works entirely in your browser. Your sensitive JSON payloads never leave your local machine.

Integration with Spring Boot & Android

Generating the class is just the first step. Here is how to integrate the generated POJOs into modern Java frameworks.

Spring Boot (REST APIs)

In Spring Boot, the @RequestBody annotation automatically maps incoming JSON to your POJO using the configured ObjectMapper (usually Jackson).

@PostMapping("/users")
public ResponseEntity<User> createUser(@RequestBody UserDTO user) {
   // 'UserDTO' is the POJO generated by this tool
   userService.save(user);
}

Android (Retrofit & Moshi)

For Android development, we recommend using Kotlin Data Classes with Moshi for a smaller footprint. Enable the "Moshi" and "Kotlin" toggles above to generate code compatible with Retrofit.

JSON Schema vs. Raw JSON: Which Source?

Many developers confuse JSON Schema with raw JSON objects. This tool focuses on converting instance data (the actual JSON) into classes.

FeatureThis Tool (Raw JSON)JSON Schema (jsonschema2pojo)
Input SourceReal Data (e.g. API Response)Validation Rules (.json files)
Use CaseQuick prototyping, consuming 3rd party APIsContract-first development, Enterprise standards
SpeedInstantRequires Build Setup (Maven/Gradle)

Comparison: Jackson vs Gson vs Moshi

FeatureJacksonGsonMoshi
Best ForSpring Boot, EnterpriseLegacy Apps, Simple ScriptsModern Android, Kotlin
Annotations@JsonProperty@SerializedName@Json
StreamingExcellentGoodExcellent (Okio)

Frequently Asked Questions

How do I handle "UnrecognizedPropertyException"?

This error happens when the JSON contains fields not present in your Java class. Use our Jackson option to add @JsonIgnoreProperties(ignoreUnknown = true) to the class level to fix this safely.

Can I generate Kotlin Data Classes?

Yes! Toggle the Language switch to "Kotlin" at the top of the converter tool. We also support Java 14+ Records for immutable data structures.

Is there an IntelliJ Plugin?

While IntelliJ IDEA has built-in support (`RoboPOJO`), our tool offers more granular control over valid annotations (Lombok, Builder) without requiring IDE restarts or plugin updates.

Common JSON to POJO Errors & Fixes

UnrecognizedPropertyException

JSON has fields not in your POJO.

Fix: @JsonIgnoreProperties(ignoreUnknown = true)

InvalidFormatException

Date/number format mismatch.

Fix: @JsonFormat(pattern = "yyyy-MM-dd")

MismatchedInputException

Expected object but got array, or vice versa.

Fix: Check if root is [] or {} and use List<T>

NullPointerException on primitives

JSON null mapped to int/boolean.

Fix: Use Integer/Boolean wrapper types

Java Records vs Traditional POJO

Java 14 introduced Records as immutable data carriers. Here's how they compare to traditional POJO classes:

✓ Java Record

public record User(
  String name,
  int age
) { }

Immutable, compact, auto-generated equals/hashCode/toString.

Traditional POJO

public class User {
  private String name;
  // + getters, setters,
  // equals, hashCode...
}

Mutable, verbose, requires Lombok or manual code.

Tip: Enable "Use Records" in the converter options to generate modern Java 14+ code.

Explore Our Guides