JSON to Kotlin Data Class Converter

Convert a JSON object or array response into Kotlin data class code for Android apps.

0 characters
0 characters

About This Tool

This JSON to Kotlin Data Class converter turns a JSON object or JSON array response into Kotlin data class code for Android apps. Paste an API response, choose a root class name, and generate model classes with inferred property types.

The converter runs in your browser and supports common JSON shapes including strings, numbers, booleans, nullable values, nested objects, and arrays. It can also add Kotlin Serialization annotations when you want @Serializable model classes.

Benefits and Use Cases

  • Convert API responses into Kotlin model classes
  • Generate nested data classes from JSON objects
  • Infer String, Int, Long, Double, Boolean, List, and nullable types
  • Add Kotlin Serialization imports and annotations
  • Create Android DTOs faster when working with Retrofit, Ktor, or local JSON files

How to Use

  1. Paste a JSON object or array into the input box.
  2. Enter the root Kotlin class name.
  3. Enable @Serializable, nullable properties, or default values if needed.
  4. Click Generate Kotlin.
  5. Copy the generated Kotlin data classes into your Android project.

Android Example

For an API response like:

{
  "id": 42,
  "first_name": "Ada",
  "active": true
}

The tool can generate:

data class User(
    val id: Int,
    val firstName: String,
    val active: Boolean
)

If Kotlin Serialization is enabled, renamed JSON keys such as first_name receive @SerialName annotations.

Frequently Asked Questions

Does this convert JSON arrays?

Yes. If the root JSON value is an array, it uses the first object shape as the root model.

Does it support nested JSON?

Yes. Nested objects and arrays of objects are generated as additional Kotlin data classes.

Is my JSON uploaded?

No. The conversion runs locally in your browser.

Which Kotlin libraries does this support?

The basic output is plain Kotlin. You can also enable Kotlin Serialization annotations with @Serializable and @SerialName.