JSON Formatter
Format JSON online: beautify messy JSON with 2 or 4 spaces or tabs, sort keys, minify it to one line and find errors. Free, runs in your browser.
Convert JSON to Java classes: a POJO with getters and setters, Lombok @Data or a record, with Gson or Jackson names. Free, runs in your browser.
Runs in your browser. Your data never leaves your device.
Paste a JSON sample and get Java classes for Android or Spring. Choose a classic POJO with private fields, getters and setters, a Lombok @Data class, or a Java record (Java 16 and later). Keys that are not valid Java names keep their JSON name through Gson's @SerializedName or Jackson's @JsonProperty, nested objects become their own classes or nested static classes, and boxed types such as Integer let missing values stay null.
A POJO (plain old Java object) is a simple class with fields, getters and setters and no framework base class. Gson and Jackson fill a POJO from JSON by matching names, so a JSON to POJO converter saves you typing every field. A sample and the kind of class it becomes:
// JSON
{"id": 7, "user_name": "sara", "tags": ["admin"]}
// Java
public class User {
private int id;
@SerializedName("user_name")
private String userName;
private List<String> tags;
public int getId() { return id; }
public void setId(int id) { this.id = id; }
// ... the other getters and setters
} Jackson (the default in Spring Boot) uses ObjectMapper and Gson (common on Android) uses fromJson. Both turn JSON text into your class and back.
// Jackson
ObjectMapper mapper = new ObjectMapper();
User user = mapper.readValue(json, User.class);
String back = mapper.writeValueAsString(user);
// Gson
Gson gson = new Gson();
User user2 = gson.fromJson(json, User.class);
String back2 = gson.toJson(user2); org.json's JSONObject and Jackson's JsonNode read values by key without a class, which is fine for a quick script. For code you keep, a class is better: the compiler checks names and types, and your IDE can complete them.
IntelliJ IDEA and Android Studio have plugins that generate POJOs from JSON; search the plugin marketplace for JSON to POJO. If your API publishes a JSON Schema instead of examples, jsonschema2pojo generates Java classes from the schema and also runs from Maven or Gradle. This tool works from a JSON sample, which is what most APIs document.
JavaScript needs no classes: JSON.parse gives you a normal object, and the JSON to TypeScript tool below adds types. If your JSON is on one long line, beautify it with the JSON formatter first so you can read it and spot mistakes.
Yes. Paste the JSON above, choose POJO, Lombok or record, and copy the classes. Nothing is installed and nothing is uploaded.
A record for read-only data on Java 16 or later; Jackson 2.12+ and Gson 2.10+ support records. Lombok @Data if the project already uses Lombok. A plain POJO works everywhere, including older Android code.
Jackson for Spring and server code, Gson for Android projects that already use it. Pick the one your project has, so you don't add a second JSON library.
No. The classes are made in your browser.
Format JSON online: beautify messy JSON with 2 or 4 spaces or tabs, sort keys, minify it to one line and find errors. Free, runs in your browser.
Check if JSON is valid and see the exact line and column of any error, with a hint on how to fix it. A free online JSON validator in your browser.
Paste JSON and get Kotlin data classes for Android, with kotlinx.serialization, Gson or Moshi names, nullable fields and defaults. Free, in your browser.
Convert JSON to null-safe Dart model classes for Flutter, with fromJson, toJson and an optional copyWith. Free, no sign-up, runs in your browser.