Free JSON to Kotlin — data class · Serializable · Moshi · Gson

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.

Your data never leaves your browser
data class · @Serializable · Moshi · Gson
Nested objects → separate classes
Nullable types for null values
Always free
JSON to Kotlin Data Class Generator   100% client-side
Use a representative JSON sample with non-null values. Null fields become nullable? with = null default.
JSON input
  Kotlin class ready

      
data class vs @Serializable vs Moshi vs Gson

Choose the style that matches your library and project type.

StyleLibraryBest 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.
How JSON types map to Kotlin types
JSON valueKotlin typeNullable
"Alice"StringString?
42IntInt?
98.5DoubleDouble?
trueBooleanBoolean?
nullAny? = null — refine manually after generating
["a","b"]List<String>List<String>?
[{…}]List<Child>List<Child>?
{…}ChildClassChildClass?
When do you need JSON to Kotlin data classes?
Android + Retrofit

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.

Kotlin Multiplatform

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 client

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.

Unit test fixtures

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.

Popular searches
json to kotlin data class json to kotlin json to kotlin class json to kotlin data class generator convert json to kotlin data class json to kotlin data class online json to kotlin data class android studio json to kotlin model json to kotlin object json to kotlin serializable

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.

4 library styles
Plain data class, kotlinx.serialization, Moshi and Gson — covering every Android and KMP project setup.
Kotlin null safety
Null values in your JSON sample become nullable Kotlin types (Type?) with = null defaults — matching Kotlin's type system.
Nested data classes
Each nested JSON object generates a separate data class — no Map<String, Any> shortcuts.
47 tools, always free
No file size limits, no watermarks, no account. Funded by non-intrusive display advertising only.
Frequently asked questions
How do I convert JSON to a Kotlin data class?
Paste your JSON sample, set the class name, choose your style (plain, @Serializable, Moshi or Gson), and click Generate. Copy the output into your Kotlin project. In Android Studio, you can also use the JSON to Kotlin Class plugin from the marketplace.
Which library should I choose — Moshi, Gson or kotlinx.serialization?
For new Android projects: Moshi with codegen — it's Kotlin-first, null-safe and faster than reflection. For Kotlin Multiplatform: kotlinx.serialization — the only option that works across all targets. For existing projects using Gson: stick with Gson unless you have a reason to migrate. All three work well with Retrofit.
How do I use the generated class with Retrofit?
Add the converter to your Retrofit builder: .addConverterFactory(GsonConverterFactory.create()) for Gson, MoshiConverterFactory.create() for Moshi, or Json.asConverterFactory() for kotlinx.serialization. Then use the class as the suspend return type: @GET("users/{id}") suspend fun getUser(@Path("id") id: Int): User.
Is the JSON to Kotlin converter free?
Yes, completely free. No file size limits, no account required. JSONshift is funded by non-intrusive display advertising.
Go up