JSON to Kotlin Data Class
Convert JSON into Kotlin data classes for Android apps.
Turn representative JSON into Kotlin models
Infer nested types and generate a copy-ready Kotlin data class starting from one realistic payload.
Kotlin
language
Root
root type
12 lines
output
Representative JSON
129 charactersKotlin output
Generated locallyTypes are inferred only from this sample. Null values become optional; verify optionality, coding keys and numeric ranges against the complete API contract.
About the JSON to Kotlin Data Class
Android apps map JSON responses to Kotlin data classes, often for use with Gson, Moshi or kotlinx.serialization.
This tool reads a JSON sample and generates Kotlin data classes, inferring types for strings, numbers, booleans, lists and nested objects.
Everything runs in your browser, so your JSON stays private.
Key features
- Generates data classes from JSON
- Infers Int, Double, Boolean, String, List and nested types
- Custom root class name
- Local, private conversion
How to use
- 1Paste a JSON sample.
- 2Set the root class name if you like.
- 3Copy the generated Kotlin data classes.
Examples
{ "id": 1, "name": "Ada" }data class Root(val id: Int, val name: String)Each JSON field becomes a typed val in the data class.
Frequently asked questions
- Which serialization libraries does this suit?
- The generated data classes work with Gson, Moshi and kotlinx.serialization. You may add annotations like @SerializedName or @Json for keys that are not valid Kotlin identifiers.
- How are null values handled?
- A null becomes a nullable String? since the real type cannot be inferred. Change it to the correct nullable type for your model.
- Does it support nested objects?
- Yes. Nested objects become their own data classes and arrays become typed Lists based on the first element.
Continue your workflow
Open a related tool to prepare your files or refine the finished result.
- Featured toolDeveloper ToolsJSON to Swift Codable
Convert JSON into Swift Codable structs for iOS apps.
Open tool - ConvertersJSON to TypeScript Converter
Generate TypeScript interfaces from a JSON sample.
Open tool - Featured toolDeveloper ToolsColor to Mobile Code
Convert a hex colour to SwiftUI, UIKit, Jetpack Compose and Android XML code.
Open tool
