JSON to Kotlin Data Classes Converter

Paste JSON and generate Kotlin data classes with package-aware downloads.

Generate Kotlin data classes from JSON

Paste JSON and get top-level Kotlin data classes with inferred nullability, nested models, collection types, and optional kotlinx.serialization annotations inspired by the JsonToKotlinClass IDE plugin.

Built for Android and KMP modeling

Use it when you need API response models, fixture types for tests, or a quick starting point before refining names and packages in your project. Set the package to match your module, such as com.example.json2kotlin, and download one file or many.

Inference behavior

Nested objects become separate data classes. Arrays merge object shapes, missing fields become nullable, and numeric values widen from Int to Long to Double when needed.

How to use the converter

  1. Paste JSON into the input pane or load the sample payload.
  2. Set the root class and package name in the properties inspector.
  3. Choose Kotlinx serialization or Plain Kotlin output.
  4. Copy the combined preview or download a single .kt file or ZIP archive.

Example output

@Serializable
data class Root(
    @SerialName("created_at")
    val createdAt: String,
    val profile: Profile,
)

@Serializable
data class Profile(
    val id: Int,
)

FAQ