kotlinx.serialization provides compiler-generated serializers and runtime formats for Kotlin on JVM, JS, and Native without reflection.
Overview
The stack pairs a Kotlin compiler plugin with a runtime library. Serializable classes and standard collections gain encoding and decoding visitors generated at compile time.
Built-in formats include JSON, Protobuf, CBOR, HOCON, and Properties, each distributed as optional artifacts. Gradle, Maven, and Bazel setup instructions show how to add the plugin and pick format dependencies.
Multiplatform projects can declare shared serialization dependencies in common source sets, with platform artifacts resolved per target. Android guidance covers default ProGuard rules for retained serializers.
Documentation on kotlinlang.org covers annotations, custom serializers, and format-specific options for application and library authors.
Key features
- Compile-time serializer generation
- JSON Protobuf CBOR support
- Kotlin multiplatform targets
- HOCON and Properties formats
- Gradle and Maven integration
- Android shrinker rules included
- Reflectionless core API
Use cases
- Kotlin API payload encoding
- Multiplatform mobile data models
- Config files with HOCON
- Protobuf services in Kotlin