# kotlin/kotlinx.serialization

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/kotlin-kotlinx-serialization).**

5,929 stars · 676 forks · Kotlin · Apache-2.0

## Links

- GitHub: https://github.com/Kotlin/kotlinx.serialization
- awesome-repositories: https://awesome-repositories.com/repository/kotlin-kotlinx-serialization.md

## Topics

`cbor` `json` `kotlin` `protobuf` `serialization`

## Description

kotlinx.serialization is an official Kotlin library that provides a multiplatform serialization framework for converting Kotlin objects to and from multiple data formats. It uses a Kotlin compiler plugin to generate serializer and deserializer code at compile time, avoiding runtime reflection and preserving type safety through annotations like `@Serializable`. The library supports JVM, JS, and Native targets with platform-specific runtime libraries, enabling consistent serialization across all Kotlin environments.

The library distinguishes itself through its multi-format encoder-decoder abstraction, allowing the same serializable class to work with JSON, CBOR, ProtoBuf, and other formats without code changes. It supports polymorphic serialization for sealed classes and interfaces via a registry of subclass serializers, and allows custom serializer registration for types not covered by automatic generation. Additional capabilities include transient property exclusion to reduce payload size, and built-in JSON serialization for converting objects to and from JSON strings.

The project integrates with Gradle, Maven, and Bazel build systems for configuring the compiler plugin, and provides ProGuard and R8 rules to retain serializers during Android code shrinking.

## Tags

### Data & Databases

- [Multiplatform Serialization Libraries](https://awesome-repositories.com/f/data-databases/data-processing-pipelines/data-serialization/kotlin-type-serialization/multiplatform-serialization-libraries.md) — Provides a multiplatform serialization framework that works consistently across JVM, JS, and Native targets.
- [Cross-Platform Serialization](https://awesome-repositories.com/f/data-databases/data-processing-pipelines/data-serialization/kotlin-type-serialization/cross-platform-serialization.md) — Provides a serialization solution that works consistently across Kotlin/JS, Kotlin/Native, and Kotlin/JVM targets.
- [Polymorphic Type Serializers](https://awesome-repositories.com/f/data-databases/data-type-managers/dynamic-type-managers/custom-type-serializers/polymorphic-type-serializers.md) — Enables serialization of sealed classes and interfaces through a registry of subclass serializers.
- [JSON Data Exchange](https://awesome-repositories.com/f/data-databases/json-data-exchange.md) — Converts Kotlin data classes to and from JSON strings for APIs, configuration files, or data storage.
- [Multi-Format Serializers](https://awesome-repositories.com/f/data-databases/multi-format-serializers.md) — Offers a unified API for encoding and decoding Kotlin objects into JSON, CBOR, ProtoBuf, and other formats.

### Part of an Awesome List

- [Multi-Format Encoder-Decoder Abstractions](https://awesome-repositories.com/f/awesome-lists/data/data-formats-and-parsing/image-format-decoders-and-encoders/multi-format-encoder-decoder-abstractions.md) — Defines a common encoder and decoder interface that allows the same serializable class to be used with JSON, CBOR, ProtoBuf, and other formats.

### Networking & Communication

- [JSON Serialization](https://awesome-repositories.com/f/networking-communication/json-serialization.md) — Converts Kotlin objects annotated with @Serializable into JSON strings using a built-in encoder. ([source](https://cdn.jsdelivr.net/gh/kotlin/kotlinx.serialization@master/README.md))

### Programming Languages & Runtimes

- [Kotlin Compiler Plugin Serializers](https://awesome-repositories.com/f/programming-languages-runtimes/ahead-of-time-compilation/serialization-code-generators/kotlin-compiler-plugin-serializers.md) — Ships a Kotlin compiler plugin that generates serializer code at compile time for annotated classes.
- [Serializer Registrations](https://awesome-repositories.com/f/programming-languages-runtimes/class-creation-customization/native-class-mappings/serializer-registrations.md) — Allows users to define and register custom serializers for types not covered by automatic generation.
- [JSON Serialization](https://awesome-repositories.com/f/programming-languages-runtimes/json-serialization.md) — Provides a built-in JSON encoder and decoder for converting Kotlin objects to and from JSON strings.
- [Serialization](https://awesome-repositories.com/f/programming-languages-runtimes/kotlin-multiplatform-logging/serialization.md) — Serializes and deserializes Kotlin objects across JVM, JS, and Native targets using a unified API.
- [Serialization Annotations](https://awesome-repositories.com/f/programming-languages-runtimes/type-annotations/type-annotations/serialization-annotations.md) — Uses @Serializable and related annotations to mark classes for automatic serializer generation.
- [Platform-Specific Runtimes](https://awesome-repositories.com/f/programming-languages-runtimes/platform-specific-runtimes.md) — Provides separate runtime artifacts for JVM, JS, and Native targets, each optimized for the respective platform.

### Software Engineering & Architecture

- [Kotlin Object Deserializers](https://awesome-repositories.com/f/software-engineering-architecture/abstract-syntax-tree-tools/internal-tree-representations/json-deserializers/kotlin-object-deserializers.md) — Parse a JSON string back into a typed Kotlin object annotated with @Serializable using a built-in decoder. ([source](https://cdn.jsdelivr.net/gh/kotlin/kotlinx.serialization@master/README.md))
- [Compiler Plugin Serializers](https://awesome-repositories.com/f/software-engineering-architecture/compile-time-code-generation/compiler-plugin-serializers.md) — Generates serializer and deserializer implementations at compile time via a Kotlin compiler plugin, avoiding runtime reflection.

### Security & Cryptography

- [Property Exclusion](https://awesome-repositories.com/f/security-cryptography/object-property-prohibitions/property-strictness/property-exclusion.md) — Marks properties with @Transient to exclude them from serialization, reducing payload size.
