JSON to Java Converter
Turn any JSON into Java POJO classes directly in your browser — no upload, no API call, no tracking. Paste JSON (or drop a .json file) and get Java classes with nested types, List fields, Jackson or Gson annotations, getters and setters, and a full type-decision report that shows exactly how each field was inferred.
What it generates
- Nested objects become their own classes, named after the property.
- Arrays become
List<T>, whereTis the element type. - Numbers become
int(fits 32 bits) orlong(larger), and decimals becomedouble. - Booleans become
boolean; strings becomeString. - Null values become
Object(a reference type that can hold null). - Annotations map each field back to its original JSON key —
@JsonProperty(Jackson) or@SerializedName(Gson), selectable, or none.
Why the report matters
Most generators hand you a class and stay silent about the guesses. This one doesn't. For every field it tells you the inferred type. For every key it shows what happened. For every array it tells you whether the element type was pinned to a concrete class or fell back to List<Object>. That is the difference between a POJO you can trust and one that quietly deserializes wrong.
Using the output
Copy the classes into a .java file. The first class is public; the nested types are package-private so they compile in a single file — split them into their own files if you prefer all public. Then deserialize with Jackson or Gson:
new ObjectMapper().readValue(json, Root.class)(Jackson)new Gson().fromJson(json, Root.class)(Gson)
How inference works (and its limits)
Array element types are inferred from the first element of each array; if the elements have differing shapes, the array falls back to List<Object> and the report says so. Type choices reflect the sample you provide — feed it a representative payload.
FAQ
Is this JSON to Java converter free?
Yes. It runs entirely in your browser, with no login, no usage limits, and no ads on this tool. Your JSON never leaves your device.
Is my JSON data safe?
Yes. All code generation happens locally in JavaScript. Your JSON is never sent to a server, logged, or stored. You can disconnect from the internet after the page loads and it will still work.
Jackson or Gson — which should I pick?
Pick whichever your project already uses. Jackson (@JsonProperty) is the Spring Boot default; Gson (@SerializedName) is common in Android and lightweight apps. Either annotation maps each field back to its original JSON key, so the class matches your payload even when the Java field name differs. Choose "None" for a plain POJO with no library dependency.
Why are field names camelCase?
Java convention is camelCase for fields, so a key like first-name becomes firstName. The original key is preserved in the annotation, and the report lists every name that changed.
How are numbers typed?
Integers that fit in 32 bits become int; larger integers become long. Decimal values become double. If you need exact decimals for money, change the field to BigDecimal after generating.
Can I convert Java back to JSON?
This tool goes JSON → Java. For the reverse direction, use the CSV to JSON converter for tabular data, or your editor's JSON support for hand-written classes.