What problem does it solve?
Kotlin data structures across apps often require conversion to and from JSON, protobuf, and other formats, and a type-safe, boilerplate-free approach makes this repeatable and safe. The kotlinx.serialization library provides a Kotlin-first, reflection-free solution with compile-time generated serializers, enabling consistent and efficient data exchange across platforms.
Core Features & Use Cases
- Kotlinx.serialization is a Kotlin-first serialization framework that avoids reflection, uses @Serializable annotations, and supports multiple formats (JSON, ProtoBuf, CBOR, HOCON, Properties).
- It integrates with Gradle and Kotlin tools to generate serializers at compile time, enabling robust data models for HTTP APIs, storage, and IPC.
- Use cases include streaming data, polymorphic hierarchies, custom serializers, and easy integration with Ktor as a serialization backend.
Quick Start
Configure Gradle with the Kotlinx Serialization plugin, add the required format dependencies, annotate data classes with @Serializable, and start encoding/decoding with Json.