JSON to Java

Free online JSON to Java tool that converts JSON data into annotated Java POJO entity classes in one click. Supports 4 serialization annotation libraries (Lombok / Jackson / Gson / Fastjson), one-click Lombok @Data simplification, optional Serializable interface, optional toString / equals / hashCode auto-generation, 4 field naming strategies, and automatic nested class generation.

Related

About JSON to Java POJO and Java entity classes

A JSON to Java converter is a utility that automatically converts a JSON data structure into standard Java POJO class code. It frees developers from the repetitive work of hand-writing package / import / private fields / getter / setter, and is especially useful for quickly turning sample JSON from API documentation into compilable Java entity classes.

POJO (Plain Old Java Object) is a Java-community term for an ordinary Java object, constrained to: ① private fields; ② public getter / setter methods to access fields; ③ no framework-inheritance dependencies (e.g. not extending HttpServlet / EJB). POJO is the core data carrier for mainstream frameworks such as Spring Boot / Hibernate / Jackson, and JSON to Java essentially turns JSON's dynamic structure into static POJO types.

This tool supports 4 mainstream serialization annotation libraries: ① Gson (Google, @SerializedName); ② Jackson (Spring Boot default, @JsonProperty + @JsonFormat); ③ Fastjson (Alibaba, @JSONField); ④ Lombok (the @Data / @Builder / @NoArgsConstructor / @AllArgsConstructor bundle). Developers can freely choose the one that matches their project's serialization framework, with no extra IDE work needed.

Lombok @Data mode is an advanced feature: when enabled, the generated Java class is only 5 lines (@Data + fields), and all getter / setter / equals / hashCode / toString are generated at compile time by Lombok. Compared with IDE template generation or hand-written POJOs, source readability improves by 80%+ and maintenance cost drops by 60%+. Note that the project must include the Lombok dependency (Maven / Gradle coordinate).

Another differentiating highlight is "ZIP multi-file download + automatic package path organization": traditional online tools only let you copy-paste a single class, while this tool can download a ZIP package in one click, containing the directory structure organized by package name (e.g. com/geekformat/pojo/). After extracting, you can directly "Import Project" it in batch into your IDE, skipping the manual step of creating package directories.

Use Cases

  • Android development: convert backend API response JSON into Java POJO entity classes, with optional Gson / Moshi / Fastjson / Jackson annotations ready for deserialization
  • Spring Boot backend: turn sample JSON from API docs into DTO / VO / Entity classes, combined with Lombok @Data to reduce boilerplate
  • Third-party API integration: convert a partner's response JSON into the corresponding Java model, picking the matching annotation (Jackson / Fastjson / Gson) for seamless integration
  • Microservice architecture: unify request / response data models for RPC interfaces so multiple teams share the same Java class definition
  • Teaching and training: in data-structure courses or Java classes, convert sample JSON to POJOs to demonstrate object-oriented modeling
  • API documentation: embed Java entity class examples in Swagger / OpenAPI / Knife4j documentation
  • Unit test preparation: convert JSON fixtures into Java classes and use Jackson to deserialize them as test data drivers
  • Data migration scripts: convert JSON config files into Java classes for strongly-typed access from business logic
  • Frontend mock alignment: backend turns the JSON model into Java first, while the frontend gets the matching TypeScript interface / Java POJO
  • Code review: convert an API response directly into a readable POJO so field naming can be discussed in code review
  • Legacy refactoring: refactor code that dynamically accesses JSONObject into strongly-typed POJO access
  • Entity / DTO multi-role modeling: from one JSON, generate UserEntity (DB layer) + UserDTO (API layer) + UserVO (view layer), each able to use different annotations
  • snake_case backend API integration: backend returns snake_case fields; the Java frontend enables "Convert to camelCase" + Gson/Jackson annotations for seamless consumption
  • DTOs that need persistence: tick "Implements Serializable" to make the POJO directly usable in Redis caching or distributed session storage

How to Use

  1. Paste a JSON object (recommended) or array into the editor on the left, or click "Sample" to load a built-in example (with nested address / company / tags).
  2. Click the "Settings" button on the toolbar (or the class-name-labeled button) and in the dialog: ① set the root class name (e.g. User) and package name (e.g. com.example.entity); ② choose the serialization annotation library (Gson / Jackson / Fastjson / Lombok / None); ③ choose the code style (toString / equals / hashCode / constructor / Serializable); ④ choose the field naming strategy (Keep as-is / camelCase / Lower case / UPPER_SNAKE).
  3. The tool auto-converts within 400ms, and the right panel shows all generated Java classes (each in its own card; the title bar shows the active annotation library and a Lombok badge). If the JSON is invalid, a "Repair JSON" button appears.
  4. Check that the class names, field names, and annotations look right. If not, edit the source JSON keys or reopen Settings to adjust the options.
  5. When satisfied, click the "Copy" button on an individual class to paste into your IDE, or click "Download ZIP" on the toolbar to download every class at once (organized by package path).

Features

  • 4 serialization annotation libraries: Gson (@SerializedName) / Jackson (@JsonProperty + @JsonFormat for dates) / Fastjson (@JSONField) / Lombok (@Data) — toggle with a single switch
  • Lombok @Data mode: auto-generates the @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor combination, shrinking a Java class from ~50 lines down to ~5 lines
  • 4 field naming strategies: Keep as-is / snake_case to camelCase (user_name → userName) / Lower case / UPPER_SNAKE constant style
  • Flexible code style: optional toString / equals / hashCode / no-args constructor / all-args constructor / implements Serializable generation
  • Smart type inference: automatically recognizes String / Integer / Double / Boolean / List<Object> / nested object types — no need to specify field types manually
  • Automatic nested class generation: nested objects are auto-converted into independent Java classes (named by uppercasing the first letter), and objects inside arrays are named by the "strip trailing plural s" rule
  • Auto-expanded array generics: JSON arrays are automatically converted into Java List<T> generics, with the element type inferred from the first item
  • Complete POJO template: generates a full .java file with package declaration + file header comment (Copyright + auto-generated timestamp) + import + private fields + getter/setter
  • ZIP multi-file download: all generated classes are organized by package path (e.g. com/example/entity/User.java) and packaged into a ZIP with directory structure in one click
  • Custom package + class name: freely set the package (e.g. com.example.entity) and root class name (e.g. User); all nested class names are derived from the root
  • Indentation control: a 2 / 4 space indent toggle on the right panel to match team code conventions
  • Copy individual class: each generated Java class has its own "Copy" button for easy paste into an IDE
  • Auto-convert + error repair: 400ms debounced auto-convert; on JSON errors, a "Repair JSON" button appears that auto-fixes common formatting mistakes (trailing commas, single quotes, etc.)
  • Sample data + file upload: built-in English sample data (with nested address / company / tags / scores) and drag-and-click upload of .json / .txt files
  • Local history: persists up to 200 recent inputs in localStorage so you can recover quickly after a refresh or accidental page close
  • Runs locally in your browser: all JSON parsing, Java generation, and ZIP packaging are done in JavaScript inside your browser — no data is uploaded to any server

Code Examples

Java: deserialize the tool's generated POJO with Jackson

java

In a Spring Boot project, the most common usage: deserialize the tool's generated POJO from an API response with Jackson.

import com.fasterxml.jackson.databind.ObjectMapper;
import com.geekformat.pojo.User;
import com.geekformat.pojo.Address;

public class ApiClient {
    private final ObjectMapper objectMapper = new ObjectMapper();

    public User getUser(int userId) throws Exception {
        // 1) Call the API to get the JSON string
        String json = httpClient.get("https://api.example.com/users/" + userId);

        // 2) Deserialize directly into the tool's generated POJO
        User user = objectMapper.readValue(json, User.class);

        // 3) Strongly-typed field access (compile-time type checking)
        System.out.println("User: " + user.getName());
        if (user.getAddress() != null) {
            System.out.println("City: " + user.getAddress().getCity());
        }
        return user;
    }

    public static void main(String[] args) throws Exception {
        ApiClient client = new ApiClient();
        User user = client.getUser(123);
        System.out.println(user.getName());
    }
}

Java: using Lombok @Data + @Builder

java

Companion usage for the tool's Lombok-mode output: build objects via the chainable builder; Lombok generates the full POJO at compile time.

import com.geekformat.pojo.User;

public class UserService {

    public User createUser() {
        // Lombok @Builder mode: chainable calls, more readable than traditional setters
        User user = User.builder()
            .id(1)
            .userName("Alice")
            .email("alice@example.com")
            .isActive(true)
            .createdAt("2026-07-08T10:00:00.000Z")
            .build();

        System.out.println(user);
        // Lombok @Data auto-generates toString():
        // User(id=1, userName=Alice, email=alice@example.com, ...)

        return user;
    }

    public boolean isValid(User user) {
        // Lombok @Data auto-generates equals() and hashCode()
        return user != null && user.getId() != null;
    }
}

/*
 * Corresponding pom.xml dependency:
 * <dependency>
 *     <groupId>org.projectlombok</groupId>
 *     <artifactId>lombok</artifactId>
 *     <version>1.18.30</version>
 *     <scope>provided</scope>
 * </dependency>
 */

Command line: unzip the tool's downloaded ZIP into your IDE

bash

The tool's download is a ZIP package (organized by package path). After extracting, you can import it directly into your IDE.

# 1) After downloading the ZIP (filename like User.zip)
unzip User.zip -d src/main/java/

# 2) Inspect the directory layout
tree src/main/java/
# src/main/java/
# └── com/
#     └── example/
#         └── entity/
#             ├── User.java
#             ├── Address.java
#             └── Company.java

# 3) In IntelliJ IDEA: right-click the com directory → "Mark Directory as" → "Sources Root"
#    Or in Eclipse: File → Import → Existing Projects into Workspace

# 4) Use it directly in a Spring Boot project
#    UserController.java
#    @PostMapping("/users")
#    public ResponseEntity<User> createUser(@RequestBody User user) {
#        userService.save(user);
#        return ResponseEntity.ok(user);
#    }

# 5) Verify it compiles
mvn compile
# [INFO] BUILD SUCCESS

# 6) (Optional) When using Lombok, remember to add the lombok dependency in pom.xml
#    <dependency>
#        <groupId>org.projectlombok</groupId>
#        <artifactId>lombok</artifactId>
#    </dependency>

FAQ

How do I convert JSON into a Java POJO class?

Paste your JSON into the input box on the left and the tool auto-converts within 400ms, or click the "Convert" button on the toolbar. Once converted, all generated Java classes appear on the right, each with its own "Copy" button. Click "Download ZIP" on the toolbar to package and download every class at once.

What JSON data structures are supported?

Two structures are supported: ① a JSON object (used as the root class, auto-generating public class RootBean { ... }); ② a JSON array (the first object in the array is used as the root class template). All nested objects are recursively processed as independent classes, and objects inside arrays are recursively processed as classes matching the List element type.

What does each generated Java class contain?

Each generated .java file contains: ① a file header comment (Copyright + auto-generated timestamp); ② a package declaration; ③ import statements (auto-importing List / Objects / Serializable / Gson / Jackson / Fastjson / Lombok as needed); ④ a public class declaration (optionally implements Serializable); ⑤ private fields (with annotations as configured); ⑥ standard getter / setter methods (or Lombok-only annotations); ⑦ optional toString / equals / hashCode methods. The result compiles directly with javac.

Can it generate Gson / Jackson / Fastjson / Lombok annotations?

Yes. In the Settings dialog, under "Serialization annotation library", choose: ① Gson (adds @SerializedName("originalKey") to every field); ② Jackson (adds @JsonProperty to every field, plus @JsonFormat on date fields); ③ Fastjson (adds @JSONField(name="originalKey") to every field); ④ Lombok (adds @Data to the class, optionally @Builder / @NoArgsConstructor / @AllArgsConstructor); ⑤ None (default, plain POJO). The chosen library is auto-imported.

What does Lombok @Data mode look like?

When Lombok is enabled, the generated Java class becomes much leaner. For example, a class User with Lombok enabled is only 5 lines: @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + field declarations. All getter / setter / equals / hashCode / toString methods are generated at compile time by Lombok, dramatically improving source readability. Note: the project must include the Lombok dependency (add the lombok coordinate to pom.xml / build.gradle) and the IDE must have the Lombok plugin installed.

How do I convert snake_case field names to camelCase?

In the Settings dialog, under "Field naming strategy", select "Convert to camelCase". The tool will then automatically convert JSON field names from snake_case to the Java-recommended naming style. For example user_name → userName, created_at → createdAt, is_active → isActive. If you also enabled Gson/Jackson/Fastjson annotations, the original snake_case string is still kept inside the annotation so deserialization keeps working.

How are nested JSON objects handled?

The tool automatically creates an independent Java class for every nested object. Naming rule: the first letter of the nested object's key is uppercased to form the class name (e.g. address → Address); for objects inside arrays, the trailing s is stripped and the first letter is uppercased (e.g. users → User). All nested classes include full fields + getter/setter + annotations.

Are array fields automatically turned into List?

Yes. JSON array fields are automatically converted to Java List<T> generics, with the element type inferred from the first item. For example ["a","b","c"] → List<String>; [{...},{...}] → List<User> (User is a new class named from the key); an empty [] defaults to List<Object>.

How do I change the root class name and package name?

There is a Settings button at the top-right of the toolbar (or a button labeled with the class name). Click it to open the settings dialog where you can set: ① the root class name (default JsonRootBean); ② the package name (default com.geekformat.pojo). After editing, all generated class names are updated, and the directory layout inside the ZIP is reorganized to match the new package path.

Is the download a single .java file or a ZIP package?

It's a ZIP package (JsonRootBean.zip) containing all generated Java classes, organized in a directory structure that mirrors the package path. For example, with package com.geekformat.pojo, the ZIP contains: com/geekformat/pojo/JsonRootBean.java, com/geekformat/pojo/Address.java, etc. You can extract with the unzip command or import it directly into your IDE.

Can I copy a single class straight into my IDE?

Yes. Each generated Java class is shown as an independent card, with a "Copy" button in the top-right corner. Clicking it puts the entire class — including package + import + class declaration + fields + annotations + getter/setter — on the clipboard, ready to paste into IntelliJ IDEA, Eclipse, VS Code, or any other IDE.

How do I generate the Lombok @Builder builder pattern?

In the Settings dialog, under "Code style": ① tick "Use Lombok @Data to simplify code" (this auto-enables the Lombok annotation library); ② tick "Generate @Builder builder pattern". The generated class will automatically include the @Builder annotation. Usage: User user = User.builder().id(1).name("Alice").build();

How do I make the generated class implement Serializable?

In the Settings dialog, under "Code style", tick "Implements Serializable". The tool will automatically: ① add implements Serializable to the class declaration; ② import java.io.Serializable. This is useful when the POJO needs to be written to a file, transferred over the network, or stored in a Redis cache.

What's the difference between JSON to Java and JSON to TypeScript?

Both convert JSON to the corresponding language's type definition, but with different focuses: ① Java generates a complete POJO class (with package + import + private fields + getter/setter) that you can compile and run directly; ② TypeScript generates an interface or type declaration that only describes the data structure, with no implementation. The right choice depends on your development language.

Can the generated code be used in a Spring Boot project?

Yes. The POJO classes generated by this tool follow the standard Java Bean convention (private fields + getter/setter) and are compatible with Spring Boot's Jackson deserialization, MVC form binding, and JPA entity definitions (added manually). If you want Lombok simplification (@Data / @Builder), you can enable it with one click in the Settings dialog — no IDE refactoring needed.

What if the JSON is invalid?

The tool automatically checks JSON validity. On error, a red error message appears on the right and a "Repair JSON" button is offered. Clicking it can auto-fix common mistakes: ① trailing commas; ② single quotes replaced with double quotes; ③ missing quotes around keys; ④ removed comments. After a successful repair, you can convert directly to Java classes.

Is my data uploaded to a server? How is my privacy handled?

Everything runs locally in your browser. All JSON parsing, Java class generation, and ZIP packaging are done in JavaScript (JSZip) inside your browser. Your input JSON and the generated Java code are never uploaded to any server and are not logged or cached in the cloud. It's safe to use sensitive JSON containing internal API fields, unreleased business structures, or unpublished API responses — closing the page clears everything.

Will converting a 10,000-line JSON be slow?

The tool has no explicit line limit, but parsing and rendering very large JSON in the browser becomes slow. Recommendations: ① split the JSON and convert in batches; ② focus on one nesting level at a time; ③ for batch generation of 100+ classes, prefer an IDE code generation plugin (e.g. MyBatis Generator, MapStruct) or a dedicated Java code generation library (JavaPoet / JOOQ).

Troubleshooting

Error: "Please enter JSON data" or similar

The left input box is empty or contains only whitespace. Make sure valid JSON is pasted, click "Sample" to load the built-in example, or click "Upload" to pick a .json / .txt file.

Error: "Unexpected token ... in JSON at position N"

The JSON is invalid. Common causes: ① a trailing comma (e.g. {"a":1,}); ② single quotes used instead of double quotes; ③ JS object syntax (e.g. {key: value}) instead of JSON (e.g. {"key": "value"}). Click "Repair JSON" to auto-fix some of these.

The generated annotations don't match the project's framework

Switch annotation libraries in the Settings dialog under "Serialization annotation library": ① Spring Boot → Jackson; ② Android → Gson; ③ Alibaba Java backend → Fastjson; ④ Want shorter code → Lombok; ⑤ Don't want any annotation library → "None". All field annotations and imports are regenerated automatically after the switch.

Lombok build fails with "cannot find symbol"

The Lombok dependency is missing. Add this to pom.xml: `<dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.30</version><scope>provided</scope></dependency>`. The IDE also needs the Lombok plugin (IntelliJ IDEA → Plugins → search Lombok → Install).

I want shorter code without using Lombok

Leave Lombok @Data off in Settings, then use traditional mode but stay compact: ① tick "Generate no-args constructor" + "Generate all-args constructor" + "Generate toString / equals / hashCode"; ② the team can batch-generate in the IDE with Postfix Completion (IntelliJ's .var / .field templates). Or just use the IDE's built-in POJO generation (Alt+Insert → Constructor / Getter / Setter).

After snake_case → camelCase, IDE reports "cannot find symbol"

"Convert to camelCase" only changes the field name, but Lombok @Data's auto-generated getter/setter follow the new field name (e.g. user_name → userName → getUserName / setUserName), so the code itself is correct. If you still see an error, check: ① whether the IDE actually recompiled; ② whether the Lombok plugin is installed and enabled; ③ clear IDE caches (File → Invalidate Caches).

Nested class name isn't what I want (e.g. categories is named Categori)

The tool uses the "strip trailing s + upper-case first letter" rule for objects in arrays, which doesn't handle irregular plurals like categories well. Suggestions: ① change the source JSON key to singular (e.g. categories → category); ② after generation, use the IDE's Rename to rename the class (and update all references).

Directory layout inside the downloaded ZIP is wrong

The directory inside the ZIP mirrors the package setting (default com/geekformat/pojo/). If the extracted location is wrong: ① change the package name (e.g. to com.example) and re-download; ② extract with unzip -d src/main/java to a specific directory; ③ or in the IDE use File → Open on the entire extracted folder.

Date field fails to deserialize in Jackson mode

The tool auto-detects ISO 8601 date strings like "2026-07-08T10:00:00.000Z" and adds @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"). If your date format is different (e.g. "2026-07-08"): ① change the source JSON to ISO 8601; ② or after generation, manually adjust the @JsonFormat pattern argument.

ZIP filenames look garbled in Windows

The ZIP filename and Java class names are English (ASCII) by default, so they won't be garbled. If your source JSON contains non-ASCII keys (so the generated field names contain non-ASCII characters), the IDE may warn about naming but the file itself is fine. The best practice is to use English (camelCase) keys in JSON, which matches Java conventions.

The page lags when generating 100+ nested classes

The tool has no explicit class count limit, but very large DOMs render slowly in browsers. Suggestions: ① split the JSON into smaller modules and convert them separately; ② use the IDE's built-in code generation tools directly (e.g. IntelliJ's JSON to POJO plugin); ③ keep nesting depth under 6 levels — otherwise, consider restructuring the JSON.

A numeric array is generated as List<Object>

This usually happens when the array is empty [], in which case it defaults to List<Object>. Add at least one sample element in the source JSON (e.g. [1,2,3]) and the tool will infer the type from the first item; or change List<Object> to List<Integer> manually after generation.

A null-valued field is generated as Object type

JSON null is treated as Object by default because the actual type cannot be determined. This is a safe default to avoid mis-judgment. If you know the type, give the field a sample value in the source JSON (e.g. "field": "" infers String), then delete the sample value after generation.

ZIP directory layout doesn't update after I change the package name

After changing the package, you must click "Convert" again (or trigger an input change so the 400ms auto-convert fires). Once Settings is closed, the next input change regenerates every file with the new package name.

I want to remove the auto-generated file header (e.g. Copyright)

The tool adds a file header with Copyright + auto-generated timestamp by default. To remove it: use the IDE's global Find & Replace, or modify the generateFileHeader function in the tool's source code (requires redeployment).

I need a "snake_case backend + Java frontend" conversion

Typical scenario: the backend API (e.g. Python / Go service) returns snake_case fields, but the Java frontend needs camelCase fields. Steps: ① In Settings, choose the Jackson or Gson annotation library; ② choose the "Convert to camelCase" field naming strategy; ③ The tool generates: field name = userName (camelCase), annotation value = "user_name" (preserves the original key), deserialization maps via the annotation, access follows Java naming conventions.

Glossary

POJO
Plain Old Java Object. Constrained to: private fields + public getter/setter + no framework dependency. The classes generated by this tool are standard POJOs.
JavaBean
An earlier Java-community term for POJO, requiring a public no-args constructor + private fields + public getter/setter. The classes generated by this tool comply with the JavaBean specification.
DTO (Data Transfer Object)
Data transfer object, commonly used as a data carrier across processes (API / RPC). The POJOs generated by this tool can serve directly as DTOs.
VO (Value Object)
Value object, usually used in the view layer (data returned by the Controller to the frontend). The POJOs generated by this tool work for this too.
Entity
Entity object, corresponding to one row in a database table. The POJOs generated by this tool can act as the base class for JPA / Hibernate @Entity (after adding annotations manually).
@SerializedName
The field-mapping annotation in Gson. In Gson mode this tool auto-adds @SerializedName("originalKey") to every field so deserialization maps the original JSON key correctly.
@JsonProperty
The field-mapping annotation in Jackson. In Jackson mode this tool auto-adds @JsonProperty("originalKey") to every field; date fields additionally get @JsonFormat to define the serialization pattern.
@JSONField
The field-mapping annotation in Alibaba's Fastjson. In Fastjson mode this tool auto-adds @JSONField(name = "originalKey") to every field.
Lombok @Data
A composite Lombok annotation equivalent to @Getter + @Setter + @ToString + @EqualsAndHashCode + @RequiredArgsConstructor. In Lombok mode this tool adds it on the class with one click.
Lombok @Builder
The Lombok annotation for the builder pattern. When ticked, this tool auto-adds it and generates a chainable builder() method.
Serializable
A Java marker interface. Once implemented, the object can be serialized (e.g. written to a file / sent over the network / stored in Redis). Ticking "Implements Serializable" in this tool automatically adds implements Serializable and imports java.io.Serializable.
Nested class
An independent Java class auto-generated by the tool for a nested JSON object. Naming rule: upper-case the first letter of the nested object's key (e.g. address → Address).
List generic
An interface in the Java Collections Framework. The tool automatically converts JSON arrays into List<T>, with T inferred from the first item (e.g. ["a"] → List<String>).
getter / setter
Standard accessor methods on a Java Bean. A getter is named getXxx() and returns the field; a setter is named setXxx(value) and assigns the field. In Lombok mode they are auto-generated by @Data; in traditional mode the tool emits them explicitly.
package declaration
The first non-comment line of a Java file, declaring the namespace the class belongs to. This tool generates it from the user-set package name and organizes the ZIP with com/xxx/yy directories.
snake_case → camelCase
A field naming strategy conversion. The tool supports auto-conversion like user_name → userName, is_active → isActive, created_at → createdAt, in line with Java naming conventions.
JSZip
A JavaScript ZIP packaging library that runs in the browser. The tool uses it to generate ZIP files in-browser with no server-side processing.
localStorage history
A browser-local key/value store (capacity roughly 5–10MB). The tool uses localStorage to persist up to 200 recent inputs.
Debounce
A frontend performance technique that coalesces high-frequency events into a single trailing call. The tool uses a 400ms debounce to avoid jank when parsing large files.
tryFixJSON
The JSON repair function built into the tool. It auto-fixes common errors like trailing commas, single-to-double quotes, missing key quotes, and comment removal.

JSON type → Java type mapping cheat sheet

Quick lookup of the JSON data types the tool can auto-infer and their corresponding Java types:

JSON value exampleDetection ruleGenerated Java typeField default value
nullvalue === nullObjectnull
true / falsetypeof value === 'boolean'Booleanfalse
42typeof value === 'number' && Number.isInteger(value)Integer0
3.14typeof value === 'number' && !Number.isInteger(value)Double0.0
"hello"typeof value === 'string'Stringnull
[...] (empty array)Array.isArray(value) && value.length === 0List<Object>new ArrayList<>()
["a","b"]Array.isArray(value) && typeof value[0] === 'string'List<String>new ArrayList<>()
[1,2,3]Array.isArray(value) && typeof value[0] === 'number'List<Integer>new ArrayList<>()
[{...},{...}]Array.isArray(value) && typeof value[0] === 'object'List<Xxx>new ArrayList<>()
{...} (nested object)typeof value === 'object' && !Array.isArray(value)Xxx (independent class)new Xxx()

4 serialization annotation libraries comparison

The 4 mainstream Java JSON serialization annotation libraries supported by the tool. Pick the one that matches your project's framework:

Annotation libraryGenerated annotationAuto importBest for
NoneNone (plain POJO)NoneFramework-free scenarios; deserialize manually with a generic library like jackson-databind
Gson@SerializedName("user_name")import com.google.gson.annotations.SerializedName;Android apps, Google Gson ecosystem, Retrofit + Gson
Jackson@JsonProperty("user_name") + @JsonFormat on date fieldsimport com.fasterxml.jackson.annotation.JsonProperty; + JsonFormatSpring Boot's default serialization framework, web backend APIs
Fastjson@JSONField(name = "user_name")import com.alibaba.fastjson.annotation.JSONField;Alibaba ecosystem, internal Java systems, high-performance deserialization
LombokClass-level @Data (+ optional @Builder / @NoArgsConstructor / @AllArgsConstructor)import lombok.Data; (+ others)Any project that wants boilerplate reduced; combines with any serialization library

4 field naming strategies comparison

The 4 field naming conversion strategies the tool supports, optimized for different JSON sources:

StrategyInput exampleOutput Java field nameBest for
Keep as-isuser_nameuser_nameJSON field names already conform to Java naming (e.g. internal APIs), or the team prefers snake_case
Convert to camelCaseuser_nameuserNameThe Java-recommended naming style; snake_case backends (e.g. Python / Go services)
Lower caseUserNameusernameIntegrating with unusual database column names (rare)
UPPER_SNAKEuser_nameUSER_NAMEJava constant definitions (public static final); not recommended for general POJO fields

Lombok @Data mode vs traditional POJO mode

Comparing the two code styles across line count, readability, and dependencies:

AspectLombok @Data modeTraditional POJO mode
Source line count~5 lines (4 annotations + fields)~50 lines (4-5 lines of getter/setter per field + class)
ReadabilityVery high (all fields and annotations visible at a glance)Medium (lots of boilerplate)
Compiled outputFull bytecode (IDE / javac generates it via the Lombok processor)Full bytecode (compiled directly)
Runtime dependencyLombok dependency required (compile time)No extra dependency
IDE supportLombok plugin required (IntelliJ / Eclipse)Native support
Maintenance costLow (just add a field)High (manually add getter/setter for every field)
Best forMedium/large projects that have already adopted LombokProjects that reject Lombok annotations; legacy maintenance

Privacy & Security

This JSON to Java tool performs all JSON parsing, Java class generation, and ZIP packaging entirely in your browser using JavaScript (JSZip). The JSON you paste and the Java code generated are never uploaded to any server, and are not recorded, cached, or stored in the cloud. It's safe to use sensitive JSON containing internal API fields, unreleased business structures, or unpublished API responses — closing the page clears everything.

Authoritative References