JSON to Java
Convert JSON to Java records or classes (POJOs) with Jackson @JsonProperty annotations, in one file you can paste and compile.
JSON
Java
How the Java classes are built
- Output is a single file: the other types are nested inside
Root, so you can paste it asRoot.javaand compile. - Every field has a Jackson
@JsonPropertywith the original key, and@JsonIgnoreProperties(ignoreUnknown = true)so new fields in the API don't break your code. - Boxed types (
Integer,Boolean) are used so missing values andnullbecomenull. Numbers too big forintbecomeLong.
Read JSON with Jackson
ObjectMapper mapper = new ObjectMapper();
Root data = mapper.readValue(json, Root.class);Records need Jackson 2.12 or newer.
Smart type detection
Objects inside arrays are merged into one type, so a key that appears in only some items is still included (as optional). Names come from the keys, and plural keys become singular: comments → Comment. Whole numbers and decimals in the same field become a decimal type. Everything runs in your browser; your JSON is never uploaded.
More free tools
JSON to TypeScriptGenerate TS interfaces from sample data.JSON to GoGo structs with json tags from sample JSON.JSON to PythonPydantic models or dataclasses from JSON.JSON to C#C# classes for System.Text.Json.JSON to RustSerde structs from sample JSON.JSON ViewerTree view, search, copy path. Handles huge files.JSON FormatterBeautify or minify JSON in one click.JSON ValidatorClear errors with exact line and column.