What is JSON → Kotlin?
Generate Kotlin data classes from JSON data instantly. Choose between Kotlinx Serialization, Jackson, or Moshi annotations.
Nested objects become their own data classes, annotated for the serialization library you choose. Output updates as you type, and everything runs in your browser.
Features
- Generate Kotlin data classes from JSON
- Kotlinx Serialization, Jackson, and Moshi support
- Nullable type handling
- Default value generation
- Nested data class generation
- Copy generated code to clipboard
How to use JSON → Kotlin
- Paste your JSON. Enter a sample JSON object.
- Select library. Choose Kotlinx Serialization, Jackson, or Moshi.
- Copy Kotlin code. Get production-ready data classes.
Examples
Generating Kotlin data classes
A small user record with a nested address, generated with the default settings.
Input
{
"id": 1,
"name": "Ada Lovelace",
"email": "ada@example.com",
"active": true,
"tags": ["admin", "dev"],
"address": { "city": "London", "zip": "EC1A" }
}Output
// To parse the JSON, install kotlin's serialization plugin and do:
//
// val json = Json { allowStructuredMapKeys = true }
// val root = json.parse(Root.serializer(), jsonString)
package com.example
import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
@Serializable
data class Root (
val id: Long,
val name: String,
val email: String,
val active: Boolean,
val tags: List<String>,
val address: Address
)
@Serializable
data class Address (
val city: String,
val zip: String
)Frequently asked questions
What serialization libraries are supported?
Kotlinx Serialization (@Serializable), Jackson (@JsonProperty), and Moshi (@Json).
How are nullable fields handled?
Nullable fields generate as String?, Int?, etc. with appropriate default values.
