JSON to Kotlin Data Class Generator

Generate Kotlin data classes with @SerializedName from JSON samples.

  • 100% client-side · your data never leaves your browser
  • Instant, no rate limits
  • Free, no sign-up
Input JSON
Kotlin data classes

Your result appears here

Paste JSON into the panel on the left — everything runs privately in your browser.

Overview

JSON to Kotlin Data Class Generator — Convert JSON

Generate Kotlin data classes from a JSON sample for Android, Ktor, or Spring. JsonDrift infers property types, emits nested data classes, and adds Gson @SerializedName annotations whenever a camelCase property differs from the JSON key. Runs entirely in your browser — nothing is uploaded.

No uploadsNo sign-upOpen source
  1. Why generate data classes from JSON?

    Kotlin data classes are the idiomatic way to model JSON payloads, and libraries like Gson, Moshi, and kotlinx.serialization map JSON onto them. Writing the classes by hand for a nested response is tedious. Generating from a real payload captures the exact fields and types so parsing works right away.

  2. What gets generated

    Each object becomes a data class; nested objects become their own data classes. Strings map to String, whole numbers to Int, decimals to Double, booleans to Boolean, and arrays to List<T>. Property names are camelCased, and a @SerializedName("...") annotation is added when the name differs from the JSON key.

    • String, Int, Double, Boolean, List<T>
    • Nested objects become nested data classes
    • @SerializedName for keys that don't match property names
    • import for Gson annotations included when needed
  3. Gson, Moshi, or kotlinx.serialization

    The generated annotations target Gson, the most common choice. For Moshi, swap @SerializedName for @Json(name = "..."); for kotlinx.serialization, use @SerialName and annotate the class with @Serializable. The class structure and types stay the same across all three.

  4. Review before shipping

    Generated classes reflect one sample. Make fields that can be missing nullable (T?) with a default, widen numeric types where needed, and consider value classes or enums for constrained fields. Treat the output as a scaffold you adjust for your API contract.

FAQ

Frequently asked questions

How do I convert JSON to a Kotlin data class?

Paste a JSON sample and JsonDrift generates data classes with the correct types and @SerializedName annotations, ready for Android or the JVM.

Which serialization library does it target?

The @SerializedName annotations target Gson. For Moshi use @Json(name), and for kotlinx.serialization use @SerialName with @Serializable — the classes are otherwise identical.

Are nested objects supported?

Yes. Nested JSON objects become their own nested data classes, and arrays become List<T>.

Is my JSON sent to a server?

No. Generation runs locally in your browser.

Continue with a related tool

All tools

Learn more in our guides

All guides