JSON to Kotlin Data Class
import kotlinx.serialization.Serializable
@Serializable
data class User(
var id: Int,
var name: String,
var email: String,
var age: Int,
var active: Boolean,
var score: Double,
var tags: List<String>,
var address: Address,
var metadata: String,
)
@Serializable
data class Address(
var street: String,
var city: String,
)What This Tool Does
JSON to Kotlin Data Class is built for deterministic developer and agent workflows.
Convert JSON to Kotlin data classes with @Serializable annotations. Supports kotlinx.serialization, Gson, and Moshi.
Use How to Use for execution steps and FAQ for constraints, policies, and edge cases.
Last updated:
This tool is provided as-is for convenience. Output should be verified before use in any production or critical context.
Agent Invocation
Best Path For Builders
Dedicated API endpoint
Deterministic outputs, machine-safe contracts, and production-ready examples.
Dedicated API
https://aidevhub.io/api/json-to-kotlin/ OpenAPI: https://aidevhub.io/api/openapi.yaml
Unified Runtime API
https://aidevhub.io/api/tools/run/?toolId=json-to-kotlin&a=...
GET and POST are supported at /api/tools/run/ with identical validation and limits.
Limit: req / s, input max 128 KB.
How to Use JSON to Kotlin Data Class
- 1
Paste your JSON data
Input a JSON object or array in the left panel. The tool parses the structure and infers Kotlin types: strings become String, integers become Int or Long, decimals become Double, booleans become Boolean, and null becomes Any?.
- 2
Configure data class options
Set the root class name (default: Root). Toggle nullable types for optional fields. Choose between data classes and regular classes. Enable @SerializedName annotations for custom JSON key mapping.
- 3
Review generated Kotlin code
The right panel shows idiomatic Kotlin data classes with proper type annotations. Nested JSON objects become separate named data classes. Copy the output directly into your Kotlin project.