Boneyard Tools

JSON to Kotlin Data Class Converter

Paste a JSON object to generate Kotlin data classes. Types are inferred for each field, and nested objects become their own data classes.

How to convert JSON to Kotlin data classes

  1. Paste a JSON object into the box.
  2. Set the root class name if you want something other than Root.
  3. Copy the generated Kotlin data classes into your project.

Examples

Object with a nested object

{"id":1,"address":{"city":"Oslo"}}
data class Root(
    val id: Int,
    val address: Address
)

data class Address(
    val city: String
)

Frequently asked questions

Is my JSON uploaded anywhere?

No. The conversion runs entirely in your browser, so your data never leaves your device.

How are field types inferred?

Whole numbers become Int, fractional numbers Double, text String, true or false Boolean, and arrays List of the first item's type.

How are nested objects handled?

Each nested object becomes its own data class named in PascalCase after its key, and the parent references it by type.

What happens with a null value?

A null value is typed as the nullable Any?, since the concrete type cannot be inferred from null alone.

Why must the input be a JSON object?

Data classes model named fields, so the converter needs an object at the root. A bare array or value cannot become a data class.

Related tools