Code Generators · Runs in your browser

JSON to Kotlin Data Class Generator

Paste a JSON sample and get ready-to-use Kotlin data classes, with nested types, arrays and optional fields worked out for you. Ideal for Android, Ktor or Spring apps.

JSON
Drop a file to load it
Kotlin
Waiting for input

How to use it

  1. Paste a representative JSON sample, such as an API response.
  2. Set the root type name and pick a style: data classes or kotlinx.serialization.
  3. Copy the Kotlin code or download it as a file.

kotlinx.serialization

With that style, classes are @Serializable and renamed keys get @SerialName.

Nullability

Fields that are sometimes missing or null become nullable types with a null default.

Integers vs. decimals

Number types come from how the number is written in your sample: 3 is an integer, 3.0 and 3.5 are decimals, and long IDs use a 64-bit type.