JSON to Kotlin Data Class Converter
Convert JSON objects into strongly-typed Kotlin Data Class definitions and data models.
To convert JSON to Kotlin Data Class, paste your JSON payload above and specify the root type name. The generator creates clean, idiomatic Kotlin Data Class code definitions instantly in your browser without uploading your JSON data to external servers.
Runs in your browser- Privacy
- Runs entirely in your browser — nothing is uploaded
- Cost
- Free, unlimited, no sign-up
From a JSON sample to a Kotlin data class
A data class is the right container for a decoded payload. The compiler writes equals, hashCode, copy and toString from the constructor properties, which is exactly what a transfer object needs and nothing beyond it. Properties are emitted as val, so the model is immutable once built.
What the serialiser still needs from you
- An annotation. The class is library-neutral as generated. kotlinx.serialization needs
@Serializableon the class; Moshi and Jackson need their own adapters or module registration. - Key mapping. Names are camelCased, so a
created_atkey becomescreatedAt. Add@SerialName("created_at")or the equivalent for your library. - Nullability. Kotlin types are non-null unless marked, and every property here arrives non-null. Add
?to anything the server may send asnull. - Absent against null. In kotlinx.serialization, giving a property a default value makes its key optional in the input, while marking it nullable only permits an explicit
null. Those are different guarantees, and no single sample can tell them apart. - Collections are typed from the first element, and
LongagainstDoubleis decided by whether the sample value had a decimal point.
For the same API on iOS, JSON to Swift emits the Codable equivalent, and JSON to Dart covers a Flutter client.
Frequently asked questions
Does this JSON to Kotlin Data Class converter upload my files?
How to use the json to kotlin data class converter
- 1Enter or paste your json.
- 2Enter or paste your root type name.
- 3Press Run, then download the result when it is ready.
Sources & specifications
Embed this tool
Put the working json to kotlin data class converter on your own site. It runs in your visitors' browsers exactly as it does here — free, no account, nothing uploaded.
Share this tool
Related tools
Last updated
More data & format tools