# JSON to Java Class Converter

Convert JSON data into Java classes with Jackson @JsonProperty annotations, private fields, getters, and setters

> Canonical page: https://elysiatools.com/en/tools/json-to-java

- **Category:** Development

- **Keywords:** json, java, class, jackson, convert, transform, codegen, json to java, JsonProperty, pojo, dto, backend

## Overview

The JSON to Java Class Converter simplifies backend development by instantly transforming raw JSON payloads into structured Java POJOs. It automatically generates private fields, standard getter and setter methods, and Jackson @JsonProperty annotations to ensure seamless serialization and deserialization.

## Inputs

- **JSON Input** (textarea): { "name": "Alice", "age": 30, "roles": \["admin", "user"\], "address": { "city": "Shanghai", "zip": "200000" } }
- **Root Type Name** (text): Root

## When to use

- When designing Data Transfer Objects (DTOs) for Java backend services that consume external JSON APIs.
- When setting up Jackson-compatible model classes for Spring Boot REST controllers.
- When converting complex, nested JSON payloads into structured, type-safe Java class hierarchies.

## How it works

- Paste your raw JSON payload into the JSON Input text area.
- Specify the name of your main Java class in the Root Type Name field.
- Copy the generated Java code containing private fields, Jackson annotations, getters, and setters.

## Use cases

- Creating DTOs for Spring Boot applications consuming third-party REST APIs.
- Generating Java model classes from mock JSON responses during API integration testing.
- Rapidly prototyping Java backend data structures from frontend JSON payloads.

## Frequently asked questions

### Does this tool support nested JSON objects?

Yes, it automatically generates nested static classes to represent nested JSON structures.

### Which JSON library annotations are used?

The tool generates Jackson @JsonProperty annotations for mapping JSON keys to Java fields.

### What Java types are mapped from JSON types?

Strings map to String, integers to int/Integer, decimals to double/Double, booleans to boolean, and arrays to List.

### Can I customize the name of the main class?

Yes, you can define the main class name using the Root Type Name option.

### Does the generated code include getters and setters?

Yes, standard Java getter and setter methods are generated for all private fields.

## Related tools

- [Data URI Generator](https://elysiatools.com/en/tools/data-uri-generator): Convert files into Data URIs (Base64 or percent-encoded) for inlining images, fonts, and assets directly into HTML, CSS, or Markdown
- [JSON Schema to Zod Schema Converter](https://elysiatools.com/en/tools/json-schema-to-zod-schema-converter): Convert JSON Schema JSON/YAML definitions into ready-to-use Zod schemas with nested objects, arrays, enums, and common validation rules
- [JSON to C# Class Converter](https://elysiatools.com/en/tools/json-to-csharp): Convert JSON data into C# classes with PascalCase properties, JsonPropertyName attributes, and nested type inference
- [JSON to Go Struct Converter](https://elysiatools.com/en/tools/json-to-go): Convert JSON data into Go struct definitions with json struct tags, exported PascalCase fields, and nested type inference
- [JSON to Kotlin Data Class Converter](https://elysiatools.com/en/tools/json-to-kotlin): Convert JSON data into Kotlin data classes with @SerializedName annotations, nullable handling, and nested type inference
- [JSON to Rust Struct Converter](https://elysiatools.com/en/tools/json-to-rust): Convert JSON data into Rust structs with serde Serialize/Deserialize derives, snake_case fields, and serde rename attributes
- [JSON to TypeScript Converter](https://elysiatools.com/en/tools/json-to-typescript): Convert JSON data into TypeScript interfaces or type aliases with union types, optional fields, and nested object inference
- [Log Sequence Diagram Converter](https://elysiatools.com/en/tools/log-sequence-diagram-converter): Convert structured service logs into Mermaid or PlantUML sequence diagrams, with optional latency and error annotations

## Samples

- [Terraform Plan JSON Samples](https://elysiatools.com/en/samples/terraform-plan-json-samples): Sample Terraform plan JSON files exported from terraform show -json style payloads for dependency visualization and change review
- [Android Serialization Java Samples](https://elysiatools.com/en/samples/android-serialization-java): Android Java serialization examples including JSON serialization, deserialization, and XML parsing
- [Chat Transcript JSON Samples](https://elysiatools.com/en/samples/chat-transcript-json): JSON examples for multi-role chat transcripts
- [JSON Samples](https://elysiatools.com/en/samples/json): JSON (JavaScript Object Notation) format examples from simple to complex structures

## Related content

- [JSON to Typed Code Generators](https://elysiatools.com/en/hubs/json-to-typed-code-generators): Generate typed models from JSON or schema evidence for TypeScript, Go, Rust, Kotlin, Java, C#, and Zod validation workflows.
