JSON to Kotlin Data Class Generator
Convert JSON to Kotlin data classes online for kotlinx.serialization, Jackson or Klaxon, with nullable types and nested classes. Free, instant and private.
π Runs entirely in your browser β nothing is uploadedKotlin data classes from a JSON sample
Kotlin data classes are a natural fit for JSON payloads, but typing them out for a large response β especially on Android, where every screen seems to call another endpoint β is tedious. This JSON to Kotlin converter generates them from a sample. Each object becomes a data class with val properties, keys are converted to camelCase with annotations that preserve the original JSON names, nested objects become their own classes, and arrays become List<T>. Fields that are absent or null in some samples become nullable types, so you get Kotlin's null-safety on exactly the properties that need it.
Type inference comes from quicktype, which merges every element in each array. Optional fields that appear in only a few items are still captured, which avoids runtime failures when the deserializer meets a key the model does not know.
kotlinx.serialization, Jackson or Klaxon
The default output targets kotlinx.serialization, the multiplatform library from JetBrains: classes are annotated with @Serializable and keys with @SerialName. Server-side projects built on Spring often prefer Jackson, which generates @JsonProperty annotations and an ObjectMapper helper. Klaxon is a lightweight alternative that some Android projects still use. If you plan to wire serialization yourself, tick Data classes only. Set the package name so the file compiles in place.
Tips for clean Kotlin models
Give the converter a full sample β several array items, optional fields populated, nested objects not empty β so nullability and types are inferred correctly. Rename the root class to your domain name before downloading. Afterwards, consider replacing strings with known values by enum class types, using Instant or LocalDate where your serializer supports them, and adding default values for fields your API omits. Generation runs entirely in your browser, so it is fine to paste real responses captured while debugging.
How to use
- Paste JSONPaste a JSON object or array, or load the sample.
- Pick a serializerChoose kotlinx.serialization, Jackson or Klaxon and set the package.
- Copy the data classesCopy the Kotlin code or download it as a .kt file.
Frequently asked questions
Which serialization libraries are supported?
How are nullable fields typed?
String? and a default of null.