JSON to Kotlin Data Class screenshot

JSON to Kotlin Data Class

Turn a JSON sample into a Kotlin data class in your browser. Optional and nullable fields are kept apart, and nothing is uploaded.

Privacy First
0 Runs
Updated 2026-11-06
No upload
Instant
No signup

What the JSON to Kotlin generator does

Each object becomes a @Serializable data class for kotlinx.serialization. A renamed key gets @SerialName, and a key that is absent from some array elements gets a null default so the decoder can omit it. A nullable field stays a required constructor parameter typed with a question mark: a value that is present and null is not the same thing as one that never arrived.

How to use it

JSON to Kotlin Data Class: paste the JSON into the box above, set Root type name (default "Root"), and press Run to get the Kotlin data class below.

Worked example

Input:

{
  "orderId": "A-1001",
  "total": 129.99,
  "currency": "EUR",
  "paid": false,
  "customer": {
    "email": "ada@example.com"
  },
  "lines": [
    {
      "sku": "X1",
      "qty": 2
    },
    {
      "sku": "X2",
      "qty": 1,
      "discount": 0
    }
  ]
}

Output:

// Generated from a JSON sample in the browser by AllTools — nothing was uploaded.
// Rename and adjust to taste; the shape is inferred from one example, not a schema.

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class Root(
    val orderId: String,
    val total: Double,
    val currency: String,
    val paid: Boolean,
    val customer: Customer,
    val lines: List<Line>,
)

@Serializable
data class Customer(
    val email: String,
)

@Serializable
data class Line(
    val sku: String,
    val qty: Long,
    val discount: Long? = null,
)

Why it runs in your browser

The conversion happens on this page with JavaScript. Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere. The page reads JSON and returns Kotlin data class; reloading the page discards both.

Each object becomes a @Serializable data class for kotlinx.serialization. A renamed key gets @SerialName, and a key that is absent from some array elements gets a null default so the decoder can omit it. A nullable field stays a required constructor parameter typed with a question mark: a value that is present and null is not the same thing as one that never arrived.

Turn a JSON sample into a Kotlin data class in your browser. Optional and nullable fields are kept apart, and nothing is uploaded.

How to use it

JSON to Kotlin Data Class: paste the JSON into the box above, set Root type name (default "Root"), and press Run to get the Kotlin data class below.

Why it runs in your browser

The conversion happens on this page with JavaScript. Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere. The page reads JSON and returns Kotlin data class; reloading the page discards both.

What to Expect

Best for

  • Converting JSON to Kotlin data class when the data is already on screen.

What this tool keeps

  • Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere.

Sample input

{ "orderId": "A-1001", "total": 129.99, "currency": "EUR", "paid": false, "customer": { "email": "ada@example.com" }, "lines": [ { "sku": "X1", "qty": 2 }, { "sku": "X2", "qty": 1, "discount": 0 } ] }

Sample output

// Generated from a JSON sample in the browser by AllTools — nothing was uploaded. // Rename and adjust to taste; the shape is inferred from one example, not a schema. import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable data class Root( val orderId: String, val total: Double, val currency: String, val paid: Boolean, val customer: Customer, val lines: List<Line>, ) @Serializable data class Customer( val email: String, ) @Serializable data class Line( val sku: String, val qty: Long, val discount: Long? = null, )

Frequently asked questions

How do I use the json to kotlin data class?

JSON to Kotlin Data Class: paste the JSON into the box above, set Root type name (default "Root"), and press Run to get the Kotlin data class below.

Is my input uploaded?

No. The text is parsed on this page with JavaScript and is never posted to a server.

Is there a size limit?

Yes: 5 MB per run. Larger input is refused with a message rather than freezing the tab.

Developer program

Build custom tools for your store

Join the SDK program to create useful ecommerce utilities for your store.