JSON to Kotlin Data Class
Data classes with val fields, camelCase names and @JsonProperty mappings out of the box.
On Android and the JVM, the Kotlin data class is the de-facto JSON model: one declaration buys equals/hashCode/copy. This tool expands JSON into a set of data classes — nested objects modeled independently, all fields val (immutable), names converted to camelCase, and @JsonProperty injected whenever the JSON key differs.
Generated classes carry @JsonIgnoreProperties(ignoreUnknown = true) by default: when the API quietly adds a field, the client keeps deserializing instead of crashing — the single most worthwhile default annotation in production.
Why immutable (val) by default
Kotlin convention: model fields are val — a parsed response should not be rewritten, and mutation belongs to copy(). val also makes data classes thread-safe by construction. Construction uses named parameters, which read better than any setter chain.
Serialization library choice
The annotations are Jackson's; Moshi users can swap @JsonProperty for @Json(name = ...) with identical mappings. The data classes themselves bind to no library — switching only touches annotations.
Frequently asked questions
- How are empty and nullable fields handled?
- Fields emit as non-null on the assumption they always exist; add ? and a default where the API may omit them. JSON null maps to the nullable Any?.
- What about array roots?
- typealias RootModelList = List<RootModel> is generated, with the element model from the first array item.
- How is this different from Android Studio plugins?
- Same logic — but zero install, offline-capable, and it chains with the site's JSON tooling (format, validate) without leaving the browser.