๐ Runs in your browser โ nothing is uploadedโ Free, no signup
JSON to Java Class Converter
Paste JSON to generate Java records, classes with getters and setters, or Lombok @Data classes โ with Jackson @JsonProperty annotations where key names need them.
0 characters
Java
When should you use the JSON to Java?
- Mapping an API response in a Spring Boot application
- Creating request and response DTOs
- Modelling JSON config or test fixtures in Java
How to use the JSON to Java
- 1
Paste JSON
Paste a sample object or array.
- 2
Choose the style
Records (Java 16+), classes with getters and setters, or classes with Lombok's @Data.
- 3
Name it
Set the class name and, optionally, a package.
- 4
Copy
Copy the code. Put each public type in its own .java file.
Examples
A record with a renamed key
JSON
{ "id": 1, "zip-code": "N1", "tags": ["a"] }Java
public record Root(
long id,
@JsonProperty("zip-code") String zipCode,
List<String> tags
) {}Common errors and how to fix them
Several public classes in one file- Java allows one public top-level type per file. Move each record or class into its own .java file.
Optional numbers are Long instead of long- Fields that can be missing or null use boxed types (Long, Double, Boolean) so they can hold null.
More from JSON Tools
Free tools that run in your browser โ no signup, nothing uploaded.
JSON Auto-Fixer & Formatter
Repair, validate, and beautify broken JSON (missing quotes, trailing commas).
JSON Validator & Linter
Check JSON syntax and see the exact line and column of every error.
JSON Viewer (Tree)
Explore JSON as a collapsible tree with search and click-to-copy paths.
JSON Editor
Edit JSON with live validation, a tree view, formatting and key sorting.
JSON Beautifier
Pretty-print and indent JSON for easy reading and debugging.
JSON Compare & Diff Tool
Find the difference between two JSON objects visually and quickly.
JSON Sorter (Sort Keys)
Sort JSON object keys alphabetically, including nested objects.
JSONPath Tester
Evaluate JSONPath expressions with filters and recursive queries.
JSON Schema Generator
Generate a JSON Schema from any sample JSON document.
JSON to Java FAQ
Jackson โ the default in Spring Boot. @JsonProperty is added whenever the Java field name differs from the JSON key.
Records (Java 16+) are concise and immutable โ ideal for DTOs. Use classes if you need setters or older Java versions.
Whole numbers become long and decimals double. Fields that can be missing or null use Long and Double so they can be null.
Reserved words and names starting with a digit are renamed (classValue, x2fa) and mapped back with @JsonProperty.
Arrays become List<T>. If the root of your JSON is an array, deserialize it as a List of the generated type.
No. Everything runs in your browser, so your JSON never leaves your device.
