JSON to Kotlin Data Class Generator

Paste JSON, get Kotlin code instantly. Private, in your browser.

Input

Output

Ready
Ln 1, Col 1

Convert JSON to Kotlin in one step

Paste JSON and get Kotlin data classes annotated for kotlinx.serialization, ready for Android, Ktor or any Kotlin project.

How to use it

  1. Paste a JSON sample into the Input panel, open a file, or drop it onto the page. A sample is already loaded so you can see the result.
  2. The Kotlin code appears instantly in the Output panel and updates as you type.
  3. Rename the top-level type under Settings → Root type name, and use Sort keys to order fields alphabetically.
  4. Copy the code or Download it as Root.kt.

What the Kotlin generator produces

  • @Serializable data class for every object shape.
  • @SerialName("key") only where the Kotlin name differs from the JSON key.
  • Optional and nullable values are typed T? with a = null default.
  • Long, Double, Boolean, List<T>, and JsonElement for mixed values.

Using the generated Kotlin code

Decode with kotlinx.serialization:

val json = Json { ignoreUnknownKeys = true }
val data = json.decodeFromString<Root>(text)
println(data.users.first().name)

More JSON tools

All tools are free and run privately in your browser.

JSON to Kotlin FAQ

Can I use Moshi or Gson instead?

Yes. Replace @Serializable with @JsonClass(generateAdapter = true) and @SerialName with @Json(name = ...) for Moshi, or use @SerializedName for Gson.

Is my data uploaded to a server?

No. The JSON to Kotlin runs entirely in your browser using JavaScript. Your data is never uploaded, logged or stored, and the tool keeps working offline after your first visit.