Programming language: Kotlin
License: Apache License 2.0
Tags: JSON    
Latest version: v1.0.1

kotlinx.serialization alternatives and similar libraries

Based on the "JSON" category.
Alternatively, view kotlinx.serialization alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of kotlinx.serialization or a related project?

Add another 'JSON' Library


Kotlin multiplatform / multi-format reflectionless serialization

official JetBrains project GitHub license TeamCity build Download

Kotlin serialization consists of a compiler plugin, that generates visitor code for serializable classes, runtime library with core serialization API and support libraries with various serialization formats.

  • Supports Kotlin classes marked as @Serializable and standard collections.
  • Provides [JSON](formats/README.md#JSON), [Protobuf](formats/README.md#ProtoBuf), [CBOR](formats/README.md#CBOR), [Hocon](formats/README.md#HOCON) and [Properties](formats/README.md#properties) formats.
  • Complete multiplatform support: JVM, JS and Native.

Table of contents

<!--- TOC -->

<!--- END -->

Introduction and references

Here is a small example.

import kotlinx.serialization.*
import kotlinx.serialization.json.*

data class Project(val name: String, val language: String)

fun main() {
    // Serializing objects
    val data = Project("kotlinx.serialization", "Kotlin")
    val string = Json.encodeToString(data)  
    println(string) // {"name":"kotlinx.serialization","language":"Kotlin"} 
    // Deserializing back into objects
    val obj = Json.decodeFromString<Project>(string)
    println(obj) // Project(name=kotlinx.serialization, language=Kotlin)

You can get the full code [here](guide/example/example-readme-01.kt).

<!--- TEST_NAME ReadmeTest -->

<!--- TEST {"name":"kotlinx.serialization","language":"Kotlin"} Project(name=kotlinx.serialization, language=Kotlin) -->

Read the [Kotlin Serialization Guide](docs/serialization-guide.md) for all details.

You can find auto-generated documentation website on GitHub Pages.


Kotlin serialization plugin is shipped with the Kotlin compiler distribution, and the IDEA plugin is bundled into the Kotlin plugin.

Using Kotlin Serialization requires Kotlin compiler 1.4.0 or higher. Make sure you have the corresponding Kotlin plugin installed in the IDE, no additional plugins for IDE are required.


Using the plugins block

You can set up the serialization plugin with the Kotlin plugin using Gradle plugins DSL:

Kotlin DSL:

plugins {
    kotlin("jvm") version "1.4.10" // or kotlin("multiplatform") or any other kotlin plugin
    kotlin("plugin.serialization") version "1.4.10"

Groovy DSL:

plugins {
    id 'org.jetbrains.kotlin.multiplatform' version '1.4.10'
    id 'org.jetbrains.kotlin.plugin.serialization' version '1.4.10'

Kotlin versions before 1.4.0 are not supported by the stable release of Kotlin serialization

Using apply plugin (the old way)

First, you have to add the serialization plugin to your classpath as the other compiler plugins:

Kotlin DSL:

buildscript {
    repositories { jcenter() }

    dependencies {
        val kotlinVersion = "1.4.10"
        classpath(kotlin("gradle-plugin", version = kotlinVersion))
        classpath(kotlin("serialization", version = kotlinVersion))

Groovy DSL:

buildscript {
    ext.kotlin_version = '1.4.10'
    repositories { jcenter() }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"

Then you can apply plugin (example in Groovy):

apply plugin: 'kotlin' // or 'kotlin-multiplatform' for multiplatform projects
apply plugin: 'kotlinx-serialization'

Dependency on the JSON library

After setting up the plugin one way or another, you have to add a dependency on the serialization library. Note that while the plugin has version the same as the compiler one, runtime library has different coordinates, repository and versioning.

Kotlin DSL:

repositories {
    // Artifacts are also available on Maven Central

dependencies {

Groovy DSL:

repositories {
    // Artifacts are also available on Maven Central

dependencies {
    implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.1"

We also provide kotlinx-serialization-core artifact that contains all serialization API but does not have bundled serialization format with it


Library should work on Android "as is". If you're using proguard, you need to add this to your proguard-rules.pro:

-keepattributes *Annotation*, InnerClasses
-dontnote kotlinx.serialization.AnnotationsKt # core serialization annotations

# kotlinx-serialization-json specific. Add this if you have java.lang.NoClassDefFoundError kotlinx.serialization.json.JsonObjectSerializer
-keepclassmembers class kotlinx.serialization.json.** {
    *** Companion;
-keepclasseswithmembers class kotlinx.serialization.json.** {
    kotlinx.serialization.KSerializer serializer(...);

# Change here com.yourcompany.yourpackage
-keep,includedescriptorclasses class com.yourcompany.yourpackage.**$$serializer { *; } # <-- change package name to your app's
-keepclassmembers class com.yourcompany.yourpackage.** { # <-- change package name to your app's
    *** Companion;
-keepclasseswithmembers class com.yourcompany.yourpackage.** { # <-- change package name to your app's
    kotlinx.serialization.KSerializer serializer(...);

You may also want to keep all custom serializers you've defined.

Multiplatform (Common, JS, Native)

Most of the modules are also available for Kotlin/JS and Kotlin/Native. You can add dependency to the required module right to the common source set:

commonMain {
    dependencies {
        // Works as common dependency as well as the platform one
        implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$serialization_version"

The same artifact coordinates can be used to depend on platform-specific artifact in platform-specific source-set.


Ensure the proper version of Kotlin and serialization version:


You can also use JCenter or https://kotlin.bintray.com/kotlinx Bintray repository.

Add serialization plugin to Kotlin compiler plugin:


Add dependency on serialization runtime library:


*Note that all licence references and agreements mentioned in the kotlinx.serialization README section above are relevant to that project's source code only.