JSON to Kotlin Data Class Generator
Generate Kotlin data classes from a JSON sample for kotlinx.serialization, Moshi or plain use, with camelCase properties and nullable defaults.
Free · No sign-up · Your inputs stay in your browser
Input
Generate Kotlin types from JSON
Output
Kotlin
540 characters
Keys become camelCase properties with @SerialName or @Json carrying the original name. Nullable or missing keys are typed T? with a null default, so decoding a payload without them does not throw. Types come from this one sample: give fields that are null here a real value to type them.
Runs in this browser. Nothing you paste is sent to a server.
About this tool
Method, assumptions, practical next steps, and limits.
Picking the library
kotlinx.serialization is the JetBrains library and works on every Kotlin target, including multiplatform; it needs the compiler plugin and @Serializable on each class. Moshi is common on Android and generates adapters with KSP when @JsonClass(generateAdapter = true) is present.
Defaults matter for decoding
kotlinx.serialization throws on a missing key unless the property has a default value, which is why nullable properties here default to null. Set Json { ignoreUnknownKeys = true } so fields added to the API later do not break older app versions.