Developer Tools
JSON to Java Class Converter
Convert JSON to Java classes, records, or Lombok types in your browser. Jackson or Gson annotations, nullable boxed types, getters and setters.
Output options
Live preview updates with every change. All parsing and inference run in your browser; the JSON you paste is not uploaded.
Used as the name of the top-level class or record. Normalised to a valid PascalCase Java identifier automatically.
Lowercased and stripped of invalid characters automatically. Reverse-domain style is conventional in Java.
Declaration style
POJO uses private fields with public get/set accessors. Record is immutable with a compact header and auto getters. Lombok @Data is mutable; Lombok @Value is immutable. Java 14 added records as a preview and Java 16 promoted them to a standard feature.
Annotation style
Annotations appear only when the JSON key does not match the Java field name verbatim (snake_case, kebab-case, leading digits, or reserved words). Jackson ships with Spring Boot; Gson is the standard Android choice.
Integer type
long is the safer default for IDs, Unix timestamps, and any value that may exceed 2,147,483,647. int saves a few bytes per record. The boxed form (Long, Integer) is used automatically when a field can be null.
Class access
Public types can be referenced from anywhere; package-private hides the type outside its package. Top-level classes are usually public and must live in a file matching their name.
Indent
The Oracle and Google Java style guides default to 4 spaces. Android, Spring Boot, and IntelliJ all follow the same default.
How to use
- Paste a JSON value into the input on the left, or click Load sample JSON to see a worked example.
- Pick a declaration style: POJO for classic mutable DTOs with getters and setters, Record for immutable Java 16+ types, Lombok @Data for mutable DTOs with @NoArgsConstructor and @AllArgsConstructor, or Lombok @Value for immutable final classes.
- Choose an annotation style (Jackson for Spring Boot, Gson for Android, or none). Annotations are emitted only when the JSON key does not match the Java field name exactly.
- Set the integer type (long for IDs and timestamps, int when you want compact memory). Keep Use boxed types for nullable fields on so Jackson and Gson can deserialize null values without throwing.
- Optionally add the package statement, switch class access to public or package-private, toggle 2 or 4 space indentation, sort properties A to Z, and turn on Separate file per class when each class will live in its own .java file.
- Click Copy Java to put the full output on your clipboard, ready to paste into your IDE.
About this tool
JSON to Java Class Converter turns any JSON value into idiomatic Java type declarations entirely in your browser. Paste an API response, a config snippet, a webhook payload, or a copied object literal, and the tool parses it with the browser's native JSON parser, walks the resulting tree, and emits one named type per object shape with field names and types that match Java conventions. Choose between four declaration styles to fit your codebase: a classic POJO with private fields and public get/set accessors for Spring controllers and legacy Java projects, a modern record with a compact header and built-in component accessors for immutable DTOs (Java 16 and later), a Lombok @Data class with @NoArgsConstructor and @AllArgsConstructor for the mutable DTO style most Spring Boot tutorials use, or a Lombok @Value class for an immutable, final, all-args constructor variant. Field names are camelCased per the Oracle and Google Java style guides, type names are PascalCased, and common initialisms (Id, Url, Api, Http, Https, Ip, Json, Uuid, Db, Sdk, Ssl, Tls) are normalised so user_id becomes userId, api_url becomes apiUrl, and tag_ids becomes tagIds without manual edits. Whenever a JSON key does not round-trip to the Java field name verbatim (snake_case, kebab-case, leading digits, reserved words), the tool emits the right serialisation annotation automatically: @JsonProperty("original_key") for Jackson (the default JSON library bundled with Spring Boot and the most common choice for backend Java) or @SerializedName("original_key") for Gson (the standard Android JSON library that ships with Retrofit). Numbers split into long or int for integers and double for anything with a fractional part, with the integer preference exposed as a toggle so you can match Unix timestamps, Twitter snowflake IDs, and Stripe object IDs without manual edits. Nullability is inferred: keys missing in some samples become nullable, keys that ever saw JSON null are also nullable, and because Java primitives cannot be null, the converter automatically swaps int for Integer, long for Long, double for Double, and boolean for Boolean whenever a field can be null so Jackson and Gson can leave the field as null at deserialisation. Lombok output adds the Lombok imports, picks the right class-level annotations, and optionally adds @Builder for fluent construction; record output emits the modern Java 16+ compact constructor header. Output options cover package declaration (kept lowercase and stripped of invalid characters), 2 or 4 space indentation, public vs package-private access on the top-level type, A to Z field sorting versus original JSON insertion order, and a separate-file mode that emits each class with its own package and import statements ready to paste into individual .java files; the single-file default nests inner types as static classes inside the root container. Useful for typing API responses for Spring Boot controllers, generating DTOs for Android Retrofit clients, modelling third-party webhook payloads, scaffolding records for Java 16+ services, prepping Lombok value classes for clean architecture DTOs, and saving the boilerplate that every pull request adding a new endpoint would otherwise need. Parsing, schema inference, and code generation run locally on your device, so the JSON you paste here never leaves your browser.
Free to use. Works in your browser. No signup, no login.
Related tools
You may also like
JSON to C# Class Converter
Generate C# classes or records (System.Text.Json or Newtonsoft) from any JSON.
Open tool
DeveloperJSON to Go Struct Converter
Generate idiomatic Go structs with json tags from any JSON value.
Open tool
DeveloperJSON to TypeScript Converter
Generate TypeScript interfaces or types from any JSON value with full inference.
Open tool
DeveloperJSON to PHP Array Converter
Turn any JSON value into an idiomatic PHP associative or numeric array.
Open tool
DeveloperJSON Formatter
Format, minify, and validate JSON in your browser.
Open tool
DeveloperJSON Schema Generator
Infer a JSON Schema document (Draft 7 or 2020-12) from any JSON value.
Open tool