JSON to Java
Java POJOs or records with Jackson annotations from a JSON sample.
About this tool
Paste JSON and get Java classes for Jackson. Choose classic POJOs with getters and setters, or compact Java 16+ records, add a package, and optionally put @JsonProperty on every field. Each class is marked with its file name.
How the Java is generated
Each JSON object becomes a class and each key a camelCase field (user_name โ userName). @JsonProperty keeps the original key wherever the names differ, nested objects become their own classes, arrays become List<T>, whole numbers long, decimals double and booleans boolean. Array items are merged before types are chosen, so a key that only some items have, or that is sometimes null, is treated as optional or nullable rather than breaking decoding. Those use boxed types (Long, Double, Boolean) so they can hold null. Java keywords used as keys, such as class or default, get a Value suffix. Public classes must live in their own files, so each one is labelled (// Address.java). Honest limits: types describe your sample. Fields that are always null become Object, and you need jackson-annotations on the classpath. JSON to Kotlin, JSON to C# and the JSON formatter are related.
Frequently asked questions
How do I convert JSON to a Java class?
Paste the JSON here and copy the generated classes into your project, one file per public class.
Should I use records or POJOs?
Records (Java 16+) are concise and immutable. Use POJOs with setters for older Java or frameworks that need mutability.
Why Long instead of long?
Boxed types can hold null, which matters for keys that are sometimes null or missing.
Is my JSON uploaded?
No. Everything runs in your browser and nothing is stored or sent.