Kotlin Serialization Guide

Kotlin Serialization is a cross-platform and multi-format framework for data serialization—converting trees of objects to strings, byte arrays, or other serial representations and back. Kotlin Serialization fully supports and enforces the Kotlin type system, making sure only valid objects can be deserialized.

Kotlin Serialization is not just a library. It is a compiler plugin that is bundled with the Kotlin compiler distribution itself. Build configuration is explained in README.md. Once the project is set up, we can start serializing some classes.

Table of contents

Chapter 1. Basic Serialization (start reading here)

Chapter 2. Builtin Classes

Chapter 3. Serializers

Chapter 4. Polymorphism

Chapter 5. JSON Features

Chapter 6. Alternative and custom formats (experimental)

Appendix A. Serialization and inline classes (experimental, IR-specific)