JSON Input
Generated Kotlin
Enter JSON data to generate Kotlin data classes
Supports data classes, kotlinx.serialization and null safety
Generate Kotlin data classes and models from JSON data structures
Enter JSON data to generate Kotlin data classes
Supports data classes, kotlinx.serialization and null safety
Use this JSON to Kotlin generator to create Kotlin data classes from JSON samples for Android and JVM backend projects.
Step 1 – Paste a JSON sample
Import to load JSON from a file, URL, or sample data.Step 2 – Choose Kotlin data class options
Class Name for the generated data class.String?, Double?).Step 3 – Review the generated code
Root Type Name, null handling, and frameworks if available.Step 4 – Use the data classes in Kotlin
Step 5 – Copy or download
Quick tips
val properties for safer models.@Json/@SerialName annotations when field names differ.// JSON input
{
"id": 123,
"name": "Maeve Winters",
"email": "maeve@example.com",
"active": true,
"roles": ["admin", "editor"],
"metadata": { "plan": "pro" },
"createdAt": "2024-03-01T10:15:00Z",
"score": 99.5,
"notes": null
}
// Generated Kotlin data classes (simplified)
data class Metadata(
val plan: String
)
data class Root(
val id: Int,
val name: String,
val email: String?,
val active: Boolean,
val roles: List<String>,
val metadata: Metadata,
val createdAt: String,
val score: Double,
val notes: Any?
)Explore more JSON and schema tools that work great alongside this JSON to Kotlin generator.
Generate Java POJOs for mixed Kotlin/Java JVM projects.
Convert JVM models into JSON examples and JSON Schema for docs and validation.
Generate a JSON Schema from JSON samples to validate payloads and contracts.
Format and validate JSON before generating data classes to avoid runtime issues.
The generator creates Kotlin data classes with support for kotlinx.serialization, Gson, and Jackson annotations for JSON serialization, plus modern Kotlin language features like null safety and data classes.
Yes! Choose 'kotlinx' as the framework to generate classes with @Serializable and @SerialName annotations for type-safe JSON serialization support.
When selecting Gson or Jackson frameworks, the generator adds appropriate annotations (@SerializedName or @JsonProperty) to fields for proper JSON serialization/deserialization.
You can specify a custom package name in the options. The generator will add the appropriate package declaration at the top of the generated Kotlin file.