JSON to Kotlin Data Class — Free Online
JSON to Kotlin data class generator — emits @Serializable classes with @SerialName annotations for kotlinx.serialization. Built for Android workflows.
PDFFlare's JSON to Kotlin data class generator emits one class per unique object shape from any JSON sample — @SerialNameannotations preserving original keys, sensible type inference (Long, Double, Boolean, List<T>). Built for Android workflows with kotlinx.serialization.
Working on iOS too? JSON to Swift Codable. Server-side Java? JSON to Java POJO.
How to Generate Kotlin Data Classes from JSON
Paste a JSON sample
An API response, a Firebase payload, or any JSON that represents the shape you want to model in Kotlin.
Click Convert to Kotlin
PDFFlare emits one data class per unique object shape with @SerialName annotations preserving the original keys.
Drop into your Android project
Paste the data classes into your .kt files. With kotlinx.serialization on the module, parsing JSON is a single Json.decodeFromString call.
When Do You Need JSON to Kotlin?
Android API integrations: You hit a REST endpoint with Retrofit or Ktor; you need a data class to map the response into. Generate it from a real payload instead of hand-typing nested fields.
Firebase / Firestore: Document data is JSON-shaped. Generate the data class once, annotate it for Firestore deserialization, and you have typed snapshots.
Multiplatform projects: Kotlin Multiplatform shares model classes between Android, iOS, and JS targets. Generate once from a JSON sample; reuse everywhere.
Migrating Java to Kotlin: Don't hand-port the POJOs — paste the JSON sample, generate fresh Kotlin data classes, and drop them into the converted file tree.
Why Choose PDFFlare's JSON to Kotlin Data Class Generator?
kotlinx.serialization Ready
@SerialName annotations preserve original keys, @Serializable classes work with Json.decodeFromString out of the box.
Idiomatic Data Classes
Immutable val properties, camelCase identifiers, Kotlin reserved words escaped with backticks where needed.
100% Browser-Based
JSON samples stay on your device — safe for production payloads.
No Signup Required
No account, no rate limits.
Frequently Asked Questions About JSON to Kotlin
Yes. Every property carries a @SerialName("originalKey") annotation, every class is marked @Serializable, and the imports kotlinx.serialization.SerialName and Serializable are already at the top of the output. Add the kotlinx-serialization plugin and you're ready to deserialize.
The class structure is library-agnostic, but the annotations are kotlinx-specific. For Moshi: swap @SerialName for @Json(name = "...") and @Serializable for @JsonClass(generateAdapter = true). For Gson: swap @SerialName for @SerializedName and remove the Serializable annotation. Field names and types stay the same.
PDFFlare's JSON To Kotlin tool runs entirely in your browser. Each unique object shape becomes its own data class. Names are inferred from property names (singularized for arrays of objects), giving you defaults like User, Post, Comment that you can rename via find-and-replace.
Mixed-type arrays produce List<JsonElement> since Kotlin doesn't have native unions. JsonElement (from kotlinx.serialization.json) preserves the original JSON dynamically; refine to a sealed interface manually if you know the shape.
Yes. Whole-number values become Long; decimal values become Double. JSON treats both as 'number' but the converter inspects each value. For Android-specific Int vs Long, refine manually based on the field's actual range.
A safe placeholder you can rename via the Root class field at the top of the tool, or with a project-wide find-and-replace. The shape never changes — only the name.
No. The conversion runs entirely in your browser — safe for production payloads, internal API responses, and JSON containing tokens or PII. Nothing leaves your device.
It produces standard data classes matching Kotlin conventions (camelCase fields, immutable val properties, single-line declarations where they fit). Manual passes can refine: convert val to var for mutable state, add default values, mark fields nullable, add custom serializers.