Why use this generator
POJO structure
Each nested object becomes its own class with private fields, getters, and setters — standard JavaBean convention. Ready for Jackson, Gson, or any JSON library.
Type mapping
JSON strings become String, integers become long, floats become double, booleans become boolean, null becomes Object. Arrays become List<T>.
Identifier safety
Field names that aren't valid Java identifiers are sanitized. Reserved keywords get an underscore suffix. Field casing follows Java conventions.
Conversion explained
1. Parse JSON
Input is parsed into a JavaScript value. The class structure is determined by walking the value tree recursively.
2. Collect classes
For each object, a Java class is generated. The class name is derived from the parent field name, capitalized. Field types are inferred from values.
3. Emit Java
Classes are emitted with private fields, public getters, and setters. Standard Java conventions are followed throughout.
JSON to Java Class Generator — frequently asked questions
Which JSON library is this compatible with?
The generated POJOs work with any JSON library: Jackson, Gson, Moshi, org.json. Fields are private with standard getters/setters — the universal JavaBean pattern.
What Java types are generated?
Strings become String, integers become long (to handle large values), floats become double, booleans become boolean, null becomes Object. Arrays become List<T>.
Are nested objects supported?
Yes — each nested object becomes its own class. The class name is derived from the field name, capitalized. For deeply nested structures, you'll get multiple classes in the output.
Can I generate records instead of classes?
Not currently. Java records (introduced in Java 16) are more concise but require a different syntax. If there's demand, we may add a "Records" output mode.
You might also like
JSON to Python
Generate Python dataclasses from JSON
JSON to Go
Generate Go structs from JSON
JSON to C#
Generate C# classes from JSON
JSON to Kotlin
Generate Kotlin data classes from JSON
JSON to TypeScript
Generate TypeScript interfaces from JSON
JSON Validator
Validate JSON syntax with detailed error messages