JSON to Kotlin Data Class
Generate Kotlin data classes from JSON, free, in your browser.
What it's for
From JSON to Kotlin Data Class in seconds
Ready for Android and Kotlin
Generates code compatible with Retrofit, kotlinx.serialization, and Room. Paste directly into your project.
100% private
Your API JSON never leaves your browser. No signup, no telemetry.
Correct types
Infers String, Int, Long, Double, Boolean, List, and nullable types with ?. Full nesting supported.
Instant
Real-time generation as you type. No buttons, no waiting.
How it works
Three steps, no hassle
Paste your JSON
Paste the JSON from your API or config file. Can be a nested object or an array.
Instant generation
The tool generates Kotlin data classes automatically, with inferred types and serialization annotations.
Copy the code
Copy the generated data classes and use them directly in your Android or Kotlin project.
FAQ
Got questions?
Data classes are a special Kotlin feature that automatically generates equals(), hashCode(), toString(), and copy() methods based on the properties declared in the primary constructor. They are ideal for representing data models, especially REST API responses, because they eliminate the boilerplate that Java would require writing manually or using Lombok.
By default, val (immutable) properties are generated, which is the recommended practice in Kotlin for data models. val means the value cannot be reassigned after initialization, making objects more predictable and thread-safe. Use var only if you need to mutate the object after creation.
Yes. The @Serializable annotation from kotlinx.serialization, Kotlin's official JSON serialization library, is added. @SerialName is also added when the JSON field name differs from Kotlin's camelCase convention, for example when the JSON uses snake_case.
When a value in the JSON is null, or when a field is not present in all objects of an array, the property is generated as a nullable type using the ? operator. For example, String? instead of String. In Kotlin, the distinction between nullable and non-nullable types is part of the type system and the compiler verifies it at compile time.
In Android development, Kotlin data classes are used mainly to model REST API responses with Retrofit, store data in local databases with Room, serialize objects to pass between Activities/Fragments as Parcelable, and as models in MVVM or MVI architectures. Since Google adopted Kotlin as the official language for Android in 2019, data classes are the de facto standard.
Kotlin on Android, kotlinx.serialization, and Retrofit for type-safe APIs
In May 2019, Google announced that Kotlin became the preferred language for Android development, displacing Java as the first choice. Since then, Kotlin adoption in Android has grown to the point where today more than 95% of the top 1000 Google Play apps use Kotlin. Data classes are one of the most valued features by Android developers precisely because they eliminate the boilerplate of Java POJOs.
kotlinx.serialization is JetBrains' official serialization library for Kotlin. Unlike Gson or Moshi, it is fully native to Kotlin, works with Kotlin Multiplatform Mobile compilation, natively supports coroutines, and generates code at compile time instead of using reflection at runtime. The @Serializable annotation on a data class is sufficient to serialize and deserialize JSON.
Retrofit, developed by Square, is the most popular library for consuming REST APIs on Android. Combined with kotlinx.serialization or Gson as a converter, it allows defining API interfaces with annotations (@GET, @POST, @Body) and Retrofit automatically generates the implementation. The data classes generated by this tool are directly compatible with Retrofit as return types or request body parameter types.