Convert JSON to Kotlin
data class.
4 library styles.
Generate Kotlin data classes with annotations for kotlinx.serialization, Moshi and Gson from any JSON sample. Nullable types, List<T> arrays, nested classes. Runs entirely in your browser.
nullable? with = null default.
Choose the style that matches your library and project type.
| Style | Library | Best for |
|---|---|---|
| data class | None (any JSON lib) | Starting point — no annotations, works as-is with any serialization library after adding the right converter. |
| @Serializable | kotlinx.serialization | Kotlin Multiplatform (KMP), Compose Multiplatform, Ktor. Official Kotlin library — first choice for new KMP projects. |
| Moshi @Json | Moshi + Retrofit | Android + Retrofit. Kotlin-first, null-safe, codegen or reflection adapter. Preferred by many Kotlin Android teams. |
| Gson @SerializedName | Gson + Retrofit | Legacy Android projects already using Gson. @SerializedName maps snake_case JSON keys to camelCase Kotlin fields. |
| JSON value | Kotlin type | Nullable |
|---|---|---|
"Alice" | String | String? |
42 | Int | Int? |
98.5 | Double | Double? |
true | Boolean | Boolean? |
null | Any? = null — refine manually after generating | |
["a","b"] | List<String> | List<String>? |
[{…}] | List<Child> | List<Child>? |
{…} | ChildClass | ChildClass? |
Android apps with Retrofit need data classes that match API response JSON. Generate from a real endpoint response, add the right annotation for your converter (Gson or Moshi), and use the class directly as the Retrofit return type. No manual field mapping.
KMP shared modules need model classes that compile to both JVM and native targets. The @Serializable style generates kotlinx.serialization models — the only officially supported serialization library for KMP, working on Android, iOS, Desktop and Web targets.
Ktor's HTTP client uses kotlinx.serialization by default. Generate @Serializable data classes from your API docs, install the ContentNegotiation plugin with JSON(), and use the class as the response type in ktor's body() or receive() calls.
Android unit tests that test ViewModel or Repository logic need fake data objects. Generate a data class from a real API response, create instances with named parameters for readable test data, and use copy() to create variants with specific field values for each test case.
Kotlin classes generated
in your browser. No IDE needed.
The entire data class generation runs in JavaScript locally. Your JSON is never transmitted to any server. The generated code follows Kotlin conventions: PascalCase class names, camelCase property names, and the annotation syntax for each library.
The output is immediately usable — paste into Android Studio or IntelliJ IDEA and the class compiles without modification. For Retrofit, add the matching converter dependency and use the class as the return type in your service interface.
