JSON to Java
Turn a JSON object or array of objects into Java classes. Keys become camelCase fields with inferred wrapper types (String, Integer, Long, Double, Boolean), nested objects become nested static classes, and arrays become List<T>. Choose plain POJOs with getters and setters, Lombok @Data classes, or Java 16 records, and optionally add a package declaration.
🔒 100% Client-Side & Private — processed locally in your browser. Files never leave your device.
Options
Your result will appear here
Type or paste your input above, adjust the options, then press Run. Tip: press Ctrl+Enter to run, and ? for every shortcut.
How it works
What gets generated
The top level must be a JSON object or an array of objects; for an array the first element shapes the root class. Every key becomes a field, and each nested object is emitted as a nested static class so the generated file compiles as a single unit. The header always imports java.util.List, and a Lombok style additionally imports lombok.Data.
Type inference and wrappers
Strings map to String, whole numbers to Integer unless they exceed int range and then to Long, decimals to Double, booleans to Boolean and nulls to Object. Arrays become List of the element type. With wrapper types enabled every field uses the boxed form, so a missing or null JSON value is representable; disabling it emits primitives such as int, which cannot hold null.
Field names come from your keys
Keys are camelCased, so user_name and user-name both become userName, and characters that are not legal in an identifier are stripped. A key that collides with a Java reserved word gets a trailing underscore, so class becomes class_. When two keys collapse to the same field name, only the first is kept.
Choosing between POJO, Lombok and records
The POJO style writes private fields with getters and setters. Lombok emits an @Data class with fields only, leaving the boilerplate to the annotation processor. The record style emits a Java 16 or newer record with a canonical constructor and nested records, which is the shortest output but requires a modern toolchain and immutable data.
Generation is local and instant
The generator runs entirely in the page — the JSON you paste is never uploaded and no request is made, so it works with the browser offline. Because the shape is inferred from a sample, a field that is absent from the sample will not appear in the generated class.
Questions
Which types are inferred?
Strings become String, whole numbers Integer (or Long when they exceed int range), decimals Double, booleans Boolean, nulls Object, nested objects a nested class, and arrays List<T>. Wrapper types are used by default so null values are safe.
How are keys turned into field names?
Keys are camelCased (user_name and user-name both become userName), invalid characters are stripped, and Java reserved words get a trailing underscore (class → class_).
What do the three styles emit?
POJO emits fields plus getters and setters; Lombok emits @Data with fields only; record emits a Java 16+ record with a canonical constructor. Nested types are emitted as nested static classes (or nested records).
Related tools
See categoryJSON to TypeScript
Generate TypeScript interfaces or type aliases from a JSON sample, with nested named types.
JSON to C# Class
Generate C# classes and record types from a JSON sample for System.Text.Json deserialization.
JSON to Go Struct
Generate idiomatic Go structs with json tags from a JSON sample, ready for encoding/json round-trips.
JSON to Swift Struct
Generate Swift Codable structs from a JSON sample so API payloads decode cleanly in iOS apps.