Skip to content
CAI
Software that uses CAICheck a score

Kotlin/kotlinx.serialization

54.1

Adequate · 25 September 2026

26.1k

lines of production code

Kotlin

primary language

4

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is the kotlinx.serialization library, a multiplatform Kotlin library for serializing data classes to and from various formats including JSON, Protocol Buffers, CBOR, HOCON, and Java Properties. It provides a unified API for encoding and decoding across JVM, JavaScript, Native, and WebAssembly targets, supporting features like polymorphism, contextual serialization, and custom format integration. The library includes platform-specific optimizations for performance and memory safety, along with comprehensive tooling for schema generation and build-time verification.

How it got here

2017–2020 — API stabilization and format expansion

55 changes.

The project stabilized the core serialization API and expanded support for multiple data formats, including JSON, Protobuf, CBOR, HOCON, and Properties. This period focused on refining internal implementations, adding platform-specific features for JS and Native targets, and introducing comprehensive test coverage and documentation examples.

2021–2022 — JSON performance and new format support

36 changes.

This period focused on optimizing JSON serialization performance through array pooling and stream integration, while introducing support for the HOCON format and Okio-based I/O. Significant effort was also dedicated to stabilizing the library via comprehensive test coverage for JSON edge cases, Protobuf schema generation, and platform-specific behaviors across JVM, Native, and JS targets.

2023–2026 — Kotlin/Wasm support and I/O integration

17 changes.

This period focused on extending kotlinx.serialization to support the Kotlin/Wasm target, including core infrastructure, JSON, and Protobuf implementations. It also introduced integration with the kotlinx-io library for high-performance JSON stream operations and added comprehensive test coverage for the new platforms and formats.

Features

Add JSON serialization support for Kotlin/Wasm targets

The JSON serialization format now supports the Kotlin/Wasm target platform. This change introduces platform-specific implementations for internal JSON processing components, including schema caching, character array pooling, string writing, and map creation for caching, enabling the library to function correctly in WebAssembly environments.

formats/json/jsWasmMain · high confidence

Add Kotlin/Wasm support to kotlinx.serialization

This change introduces the core serialization infrastructure for the Kotlin/Wasm target. It adds platform-specific implementations for serializer caching, array handling, and built-in type serializers (including Duration, Instant, and Uuid). It also defines the \SerializableWith\ annotation and handles WASM-specific constraints, such as requiring explicit serializers for interfaces and enums without \@Serializable\.

core/wasmMain · high confidence

Add Okio integration for JSON serialization

Users can now serialize and deserialize JSON directly to and from Okio's BufferedSink and BufferedSource types. This new integration provides extension functions on the Json class, including encodeToBufferedSink for writing, decodeFromBufferedSource for reading single objects, and decodeBufferedSourceToSequence for lazy, streaming deserialization of multiple elements.

formats/json-okio/commonMain/src/kotlinx/serialization/json/okio · high confidence

Add WASM support for Protobuf byte reversal

The Protobuf serialization format now supports the Kotlin/WASM target. This change introduces a platform-specific implementation for byte-reversal operations (Int and Long) required by the internal serialization logic, ensuring correct behavior on WebAssembly platforms.

formats/protobuf/wasmMain · high confidence

Add kotlinx-io integration for JSON I/O streams

The JSON I/O module now supports the kotlinx-io library, introducing new extension functions \encodeToSink\ and \decodeFromSource\ to serialize and deserialize JSON directly to and from \kotlinx.io\ \Sink\ and \Source\ objects. This integration includes optimized internal readers and writers (\KxIoReader\ and \KxIoJsonWriter\) that leverage specialized methods like \writeDecimalLong\ and efficient ASCII handling to improve performance for stream-based JSON operations.

formats/json-io/commonMain · high confidence

Added internal stream support for Okio integration

The library now includes internal reader and writer implementations for Okio's BufferedSource and BufferedSink, enabling JSON serialization and deserialization directly to and from Okio streams. This addition supports efficient handling of ASCII data and correctly processes UTF-16 surrogate pairs for characters outside the Basic Multilingual Plane, forming the core infrastructure for the new Okio format support.

formats/json-okio/commonMain/src/kotlinx/serialization/json/okio/internal · high confidence

CBOR format adds COSE compliance features and configuration options

The CBOR serialization format now includes support for COSE (CBOR Object Signing and Encryption) compliance. Users can enable a preconfigured \Cbor.CoseCompliant\ instance that enforces definite length encoding, verifies all tags, and prefers CBOR labels over serial names. New configuration flags allow fine-grained control over tag encoding and verification (\encodeKeyTags\, \encodeValueTags\, \encodeObjectTags\, \verifyKeyTags\, \verifyValueTags\, \verifyObjectTags\), as well as \useDefiniteLengthEncoding\ and \preferCborLabelsOverNames\. Additionally, new annotations \@ByteString\, \@CborArray\, \@CborLabel\, \@ValueTags\, \@KeyTags\, and \@ObjectTags\ provide explicit control over CBOR major types and tagging semantics, while \CborEncoder\ and \CborDecoder\ interfaces expose the current configuration for custom serializers.

formats/cbor/commonMain/src/kotlinx/serialization/cbor · high confidence

Initial implementation of the HOCON serialization format

The HOCON format is now available for serializing and deserializing Kotlin data classes. This release introduces the core encoder and decoder infrastructure, enabling the conversion of standard types (such as strings, numbers, and collections) to and from HOCON configuration structures. It also adds built-in support for serializing Duration and ConfigMemorySize types, allowing users to work with time intervals and memory sizes using standard HOCON units (e.g., '2 m', '1 MiB').

formats/hocon/src/main · high confidence

Initial support for HOCON configuration serialization

Users can now serialize and deserialize Kotlin objects to and from HOCON (Human-Optimized Config Object Notation) format using the new Hocon SerialFormat. This feature allows converting Kotlin data classes into Lightbend's Config objects and vice versa, with specific support for encoding and decoding Duration values using standard HOCON time units (e.g., '2 m' for 120 seconds). The implementation also supports polymorphic serialization, configurable naming conventions, and contextual serializers for Java Duration and ConfigMemorySize types.

hocon · high confidence

Integration with kotlinx-io library

The JSON IO module now integrates with the kotlinx-io library, exposing new extension functions on the Json class to decode from and encode to kotlinx-io Source and Sink streams. This includes functions for decoding to a sequence with configurable mode, allowing users to leverage the high-performance I/O primitives provided by kotlinx-io for JSON serialization and deserialization.

formats/json-io · high confidence

Introduce Properties serialization format for Map-based storage

Adds a new \Properties\ serialization format that transforms serializable class properties into a flat \Map\ with string keys and primitive values (or strings). This format supports nested objects by prefixing keys (e.g., \data.property1\) and lists by index (e.g., \l.N.\). It includes specific mappers for encoding to \Map\<String, Any\>\ and \Map\<String, String\>\, and handles polymorphic serialization by storing type information in a \type\ key. The implementation is marked as experimental.

properties · high confidence

Introduce context-aware descriptor introspection for polymorphic and contextual serialization

Added the \capturedKClass\ extension property to \SerialDescriptor\ and corresponding \SerializersModule\ lookup functions (\getContextualDescriptor\, \getPolymorphicDescriptors\) to enable runtime introspection of the actual Kotlin class behind contextual or open polymorphic serialization. This allows schema introspection tools and applications to resolve the specific types involved in contextual or polymorphic serialization at runtime, rather than relying solely on static descriptor information.

core/commonMain/src/kotlinx/serialization/descriptors · high confidence

Introduction of Kotlinx Serialization JSON format core components

This change introduces the foundational classes and APIs for the JSON serialization format in kotlinx.serialization. It adds the main \Json\ entry point and its \JsonConfiguration\ for settings like \ignoreUnknownKeys\ and \prettyPrint\, along with DSL builders (\buildJsonObject\, \buildJsonArray\) for constructing JSON trees. The update also includes new annotations such as \@JsonNames\ for alternative property names, \@JsonIgnoreUnknownKeys\ for per-class unknown key handling, and \@JsonClassDiscriminator\ for polymorphic serialization, as well as the \JsonContentPolymorphicSerializer\ for content-based type resolution.

formats/json/commonMain/src/kotlinx/serialization/json · high confidence

New JVM stream integration and lazy sequence decoding

The JVM module now provides direct integration with Java I/O streams, adding \encodeToStream\ and \decodeFromStream\ functions to serialize and deserialize JSON directly to and from \OutputStream\ and \InputStream\ instances. Additionally, a new \decodeToSequence\ API allows users to lazily read multiple JSON objects from a stream as a \Sequence\, enabling efficient processing of large or infinite data sources without loading everything into memory at once.

formats/json/jvmMain/src/kotlinx/serialization/json · high confidence

New JsonTransformingSerializer for custom JSON manipulation

The library introduces \JsonTransformingSerializer\, a new base class that allows developers to apply custom transformations to the abstract JSON representation (\JsonElement\) during both serialization and deserialization. This enables use cases such as unwrapping lists or modifying JSON structure before it is encoded or after it is decoded, providing a flexible way to handle non-standard JSON formats without writing full custom serializers.

json · high confidence

New Okio integration for JSON serialization

This release introduces a new \kotlinx-serialization-json-okio\ module that enables direct serialization and deserialization of JSON using Okio's \BufferedSource\ and \BufferedSink\ types. Users can now leverage extension functions like \decodeFromBufferedSource\, \encodeToBufferedSink\, and \decodeBufferedSourceToSequence\ on their \Json\ instances, facilitating efficient I/O operations with Okio streams across supported platforms including iOS, macOS, Linux, Windows, JS, Wasm, and WatchOS.

formats/json-okio/api · high confidence

New built-in serializers for Long as String and Instant components

The builtins module now includes LongAsStringSerializer, which encodes Long values as strings to ensure safe interoperability with clients that have limited number precision (such as JavaScript), and InstantComponentSerializer, which encodes kotlin.time.Instant as a structure containing epochSeconds and nanosecondsOfSecond fields.

core/commonMain/src/kotlinx/serialization/builtins · high confidence

New executable code examples for the serialization guide

The guide now includes a comprehensive set of runnable Kotlin code snippets (generated via Knit) covering basic serialization, built-in types, class configuration, and format-specific usage for JSON, CBOR, and ProtoBuf. These examples demonstrate practical usage of features such as \@Serializable\, \@SerialName\, \@EncodeDefault\, \@JsonIgnoreUnknownKeys\, \@JsonNames\, and custom encoder/decoder implementations, providing users with verified reference code for common serialization scenarios.

guide/example · high confidence

Stabilize Properties serialization format API

The public API for the \kotlinx-serialization-properties\ module is now stabilized, exposing the \Properties\ class as a \SerialFormat\ implementation. This format allows users to serialize and deserialize data to and from \Map\<String, Any\>\ and \Map\<String, String\>\ structures via methods like \encodeToMap\, \decodeFromMap\, \encodeToStringMap\, and \decodeFromStringMap\. The API includes a \Default\ singleton instance and a factory function to create instances with a custom \SerializersModule\, providing a unified way to handle property-based serialization across supported platforms.

formats/properties/api · high confidence

Support for JSON comments via new lexer implementations

The JSON lexer infrastructure has been refactored to introduce dedicated lexer classes that support parsing JSON with comments. New files \CommentLexers.kt\ and updated factory functions in \StringJsonLexer.kt\ and \BufferedJsonLexer.kt\ implement \StringJsonLexerWithComments\ and \BufferedJsonLexerWithComments\, which extend the base \AbstractJsonLexer\ to skip both single-line (\//\) and block (\/\* \*/\) comments during tokenization. This change enables the \allowComments\ configuration flag to function correctly by routing the parser through these comment-aware implementations when the flag is enabled, while maintaining performance for non-comment JSON by keeping the standard lexers separate.

formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer · high confidence

Support for dynamic JavaScript object serialization and deserialization

The Kotlin/JS JSON module now includes \Dynamics.kt\, which adds \decodeFromDynamic\ and \encodeToDynamic\ extension functions to the \Json\ class. This allows users to directly convert native JavaScript objects into Kotlin data structures and vice versa, verifying types during decoding. The implementation supports array-based polymorphism if enabled in the JSON configuration, handles top-level primitives, and imposes specific limitations on \Long\ values (capped at \abs(2^53-1)\ for precision) and Map keys (restricted to String, primitive, or enum types).

formats/json/jsMain/src/kotlinx/serialization/json · high confidence

Support for object-based serialization and deserialization of polymorphic types in JSON on JS platform

This change introduces new internal decoders and encoders (DynamicDecoders.kt and DynamicEncoders.kt) for the JS platform, enabling the serialization and deserialization of Kotlin data structures to and from plain JavaScript objects (dynamic types). The implementation supports polymorphic serialization using discriminators, handles explicit nulls configuration, and includes specific logic for coercing input values and managing enum names. This allows JS-specific code to interact with kotlinx.serialization using native JavaScript object structures rather than JSON strings.

formats/json/jsMain/src/kotlinx/serialization/json/internal · high confidence

Removals

Removal of legacy serialization runtime and format implementations

The legacy serialization runtime library, including the core \Serialization.kt\ definitions, built-in serializers, and format-specific implementations for JSON and CBOR, has been removed from this module. This change eliminates the deprecated serialization API and its associated code, aligning with the migration of the KotlinX serialization runtime to a separate project.

src/main · high confidence

Architecture

Add module-info.java for HOCON format module

The HOCON format module now includes a module-info.java descriptor, explicitly declaring its dependencies on the Kotlin standard library, kotlinx.serialization core, and typesafe.config, and exporting the kotlinx.serialization.hocon package. This change supports Java Platform Module System (JPMS) integration and helps prevent IDE issues related to module compilation.

formats/hocon/src/mainModule · high confidence

Behavioural changes

Add internal stream abstractions for CBOR serialization

The CBOR format module now includes internal \ByteArrayInput\ and \ByteArrayOutput\ classes to handle byte array reading and writing. These new internal utilities provide the underlying stream mechanics required for CBOR encoding and decoding, supporting the broader CBOR feature additions and API stabilization efforts.

cbor · high confidence

Added JVM-specific byte reversal implementation and SDK verification token

The JVM module now includes a dedicated implementation for reversing byte order in Int and Long values, delegating to the standard Java library methods (Integer.reverseBytes and Long.reverseBytes). Additionally, a verification token file has been added to the resources to support SDK verification for the published module.

formats/protobuf/jvmMain · high confidence

Added Java 9+ module descriptors for serialization modules

This change introduces explicit \module-info.java\ files for the core serialization library and its format-specific modules (CBOR, JSON, Properties, and Protobuf). By defining these Java Platform Module System (JPMS) modules, the library now properly declares its package exports and dependencies (such as \kotlin.stdlib\ and \kotlinx.serialization.core\), which resolves IDE compatibility issues and ensures correct module path resolution for users building Java 9+ applications.

(repo-wide) · high confidence

Added native byte-reversal implementations for Protobuf serialization

The Protobuf serialization module now includes platform-specific implementations for reversing byte order on JavaScript and Native targets. This change adds \Bytes.kt\ files to the \jsMain\ and \nativeMain\ source sets, providing \actual\ functions for \Int\ and \Long\ that handle byte-swapping logic required for correct serialization on these platforms.

formats/protobuf/jsMain, formats/protobuf/nativeMain · high confidence

Added verification token for kotlinx-serialization-core-jvm SDK

A new verification.properties file has been added to the core-jvm resources, containing a specific token for the org.jetbrains.kotlinx:kotlinx-serialization-core-jvm SDK. This file serves as a verification mechanism for the serialization library within the JVM core module.

core/jvmMain/resources · low confidence

Added verification tokens for published JVM serialization modules

Verification property files containing tokens have been added to the resources of the kotlinx-serialization-cbor-jvm, kotlinx-serialization-json-okio-jvm, kotlinx-serialization-json-jvm, and kotlinx-serialization-properties-jvm modules. These files support the verification of the published SDK artifacts.

(repo-wide) · high confidence

Build system now uses JetBrains cache redirector for Maven repositories

The build configuration now automatically redirects downloads from major public repositories (such as Maven Central, Gradle Plugins, Clojars, and Google's Android repositories) through JetBrains' cache-redirector service. This change is implemented via a new settings plugin that intercepts repository URL configurations in the build script and project repositories, aiming to improve build performance and reliability by leveraging a centralized caching layer.

build-settings-logic · high confidence

Build system restructured with new Gradle conventions and compiler options

The buildSrc module has been completely rewritten to use modern Gradle conventions and Kotlin DSL. This introduces a new CompilerOptions.kt file that centralizes default compiler arguments, including enabling the Unused Return Value checker and setting Java 8 compatibility. Native targets are now configured to run tests in release mode, and the build system respects overridden language versions when creating verifyModule tasks. Additionally, the build now includes conventions for JPMS modularity, Kover coverage verification, and cache redirectors for Yarn and NPM, while suppressing deprecation warnings for removed or deprecated native targets like watchosArm32 and apple x64.

buildSrc · high confidence

CBOR format API stabilization and COSE compliance

The kotlinx-serialization-cbor module has stabilized its public API, introducing a new CborBuilder configuration pattern and adding COSE (CBOR Object Signing and Encryption) compliance support via the Cbor.Default.CoseCompliant instance. The API now exposes explicit configuration options for tag verification (verifyKeyTags, verifyObjectTags, verifyValueTags), definite length encoding, and ignoring unknown keys. Additionally, a typo in the BIGNUM\_NEGATIVE tag constant has been corrected (BIGNUM\_NEGAIVE -\> BIGNUM\_NEGATIVE), ensuring accurate tag handling for large negative numbers.

formats/cbor/api · high confidence

CBOR format implementation refactored with improved error reporting and tag handling

The internal CBOR decoder and encoder have been restructured to support COSE compliance features, including explicit handling of CBOR labels, key/value tags, and object tags. Decoding errors now include specific tag information to aid debugging, and the decoder correctly skips structures when the ignoreUnknownKeys setting is enabled. Additionally, unsigned integer types are now encoded as positive integers, and byte string handling has been refined to support both explicit ByteString annotations and inline value classes.

formats/cbor/commonMain/src/kotlinx/serialization/cbor/internal · high confidence

Improved serializer caching stability and memory safety on JVM

The JVM serialization module now uses a new internal caching mechanism that leverages ClassValue with soft references to prevent class loader leaks, while falling back to ConcurrentHashMap for environments like Android where ClassValue is unavailable. This change addresses memory leaks caused by invalid KTypeWrapper equality checks and ensures that serializers for parametrized types are correctly cached across different class loaders, resulting in more stable runtime behavior and reduced memory consumption.

core/jvmMain/src · high confidence

Integration tests now use Gradle 8.7 via the JetBrains cache redirector

The integration-test/gradle location has been updated to use Gradle 8.7, replacing previous versions. The Gradle wrapper properties now point to the JetBrains cache redirector (services.gradle.org) for downloading the distribution, which should improve download reliability and speed for the integration tests.

integration-test/gradle · high confidence

Internal JSON parsing and encoding engine refactored

The internal JSON parsing and encoding engine has been restructured into a new set of dedicated components to improve performance, maintainability, and error handling. This change introduces a new \JsonPath\ system for accurate error reporting, a \CharArrayPool\ for buffer reuse, and a \JsonTreeReader\ for converting JSON to \JsonElement\ trees. It also adds a \FormatLanguage\ annotation for IDE support, a \JsonSerializersModuleValidator\ to enforce polymorphic serialization rules at registration time, and new \InternalJsonWriter\/\InternalJsonReader\ interfaces to facilitate integration with external I/O libraries like Okio and kotlinx-io.

formats/json/commonMain/src/kotlinx/serialization/json/internal · high confidence

Internal serialization engine refactoring and new built-in type support

The internal serialization engine has been restructured with new files handling core serialization logic, including a new AbstractPolymorphicSerializer for multiplatform polymorphic types, dedicated serializers for kotlin.time.Instant, kotlin.time.Duration, and kotlin.uuid.Uuid, and improved collection and map descriptor handling. The codebase now supports serialization of kotlin.Nothing (throwing appropriate exceptions), implements stable hashCode/equals for descriptors, and introduces caching mechanisms for serial names and serializers to improve performance. Additionally, internal utilities for hex conversion, platform-specific serializer lookup, and missing field exception handling have been consolidated.

core/commonMain/src/kotlinx/serialization/internal · high confidence

Introduction of AbstractEncoder and AbstractDecoder base classes

The encoding module now provides AbstractEncoder and AbstractDecoder, which serve as skeleton implementations for Encoder and Decoder respectively. These classes simplify the creation of custom serialization formats by offering default implementations for primitive decoding and encoding methods that delegate to a generic decodeValue/encodeValue mechanism, as well as handling structure boundaries and element encoding checks via encodeElement. Additionally, the ChunkedDecoder interface is deprecated, indicating that chunk-based string decoding support is being phased out in subsequent releases.

core/commonMain/src/kotlinx/serialization/encoding · high confidence

JS platform serialization support and builtins initialization

The JS target now includes a dedicated internal platform implementation that initializes the builtins serializer map, explicitly adding support for kotlin.time.Instant and kotlin.uuid.Uuid serializers alongside standard primitives. This change also implements robust serializer lookup for the Nothing type and interfaces on JS, ensuring that serializer resolution does not fail with runtime errors for these edge cases.

core/jsMain/src/kotlinx/serialization/internal · high confidence

JVM-specific serializer resolution and builtins initialization

The library now includes a new JVM-specific platform implementation that handles serializer discovery via reflection, including support for named companion objects and improved handling of Java objects to prevent access errors. It also initializes the builtins map with standard primitive serializers and adds an annotation to suppress Android API compatibility warnings for JVM-only code.

core/jvmMain/src/kotlinx/serialization/internal · high confidence

Native JSON internal implementation updates

This change introduces platform-specific implementations for the native target within the JSON serialization module. It adds a character array pooling mechanism (JsonLexerBufferPool) to optimize memory usage during input stream decoding, implements the FormatLanguage annotation for native builds, provides a StringJsonWriter for efficient string-based JSON output, and defines a native-compatible cache map creation function using HashMap.

formats/json/nativeMain/src/kotlinx/serialization/json/internal · high confidence

Native platform serializer initialization and caching implementation

The Kotlin/Native serialization runtime now includes a dedicated platform-specific implementation for initializing built-in serializers and managing serializer caches. This change introduces support for serializing \kotlin.time.Instant\, \kotlin.uuid.Uuid\, and \kotlin.time.Duration\ types on Native targets. It also implements a caching mechanism for serializer lookups to improve performance and updates the error messaging to provide specific guidance for Native users when serializers are not registered (e.g., requiring \@Serializable\ for enums or \PolymorphicSerializer\ for interfaces).

core/nativeMain · high confidence

New JSON configuration options and polymorphic control modes

The JSON API now exposes new configuration flags and enums that give users finer control over parsing and serialization behavior. Users can now configure \ClassDiscriminatorMode\ (with values \ALL\_JSON\_OBJECTS\, \NONE\, and \POLYMORPHIC\) to adjust how polymorphic types are distinguished in JSON. Additionally, the \JsonBuilder\ and \JsonConfiguration\ classes expose settings such as \allowComments\, \allowTrailingComma\, \decodeEnumsCaseInsensitive\, \explicitNulls\, and \maxNestingDepth\, allowing users to relax strict JSON syntax requirements, handle enum case sensitivity, control null representation, and prevent stack overflows from deeply nested structures.

formats/json/api · high confidence

Optimized JSON stream decoding with array pooling and Java 8 compatibility fixes

The internal JSON stream decoding logic has been rewritten to significantly improve performance and stability. A new array pooling system (ArrayPools) reuses CharArray and ByteArray instances to reduce garbage collection pressure during encoding and decoding. The CharsetReader and stream writers now use these pooled buffers and a hand-rolled UTF-8 transcoding path, which also resolves NoSuchMethodError issues on Java 8 by avoiding specific ByteBuffer API methods that were unavailable in that version. Additionally, a new ConcurrentHashMap-based cache is used on JVM to improve thread-safe caching performance.

formats/json/jvmMain/src/kotlinx/serialization/json/internal · high confidence

Preserve unknown fields in ProtoBuf serialization

The ProtoBuf format now supports preserving unknown fields during deserialization. A new internal serializer, ProtoUnknownFieldHolderSerializer, along with supporting stream utilities, enables the library to capture and retain raw bytes for fields not defined in the schema, ensuring that unrecognized data is not silently discarded.

protobuf · high confidence

ProtoBuf format API stabilization and unknown field support

The ProtoBuf serialization format has undergone API stabilization, renaming core methods from dump/load to encodeToByteArray/decodeFromByteArray and encodeToHexString/decodeFromHexString for consistency with other formats. This update introduces support for preserving unknown fields during deserialization via the new ProtoUnknownFieldHolder class, allowing applications to retain data from newer schema versions. Additionally, new annotations (@ProtoNumber, @ProtoOneOf, @ProtoPacked, @ProtoType) and the ProtoIntegerType enum provide finer control over protobuf encoding details, while the ProtoBufSchemaGenerator enables automatic generation of .proto schema files from Kotlin serializable classes.

formats/protobuf/api · high confidence

ProtoBuf format rework with unknown field preservation and oneof support

The ProtoBuf serialization format has been restructured to introduce a builder-based configuration pattern (replacing direct instantiation) and add support for preserving unknown fields via the new ProtoUnknownFieldHolder class. The format now also supports protobuf oneof declarations through the ProtoOneOf annotation and allows explicit control over packed array encoding for collections using the ProtoPacked annotation. Additionally, the default behavior for encoding default values has changed, with encodeDefaults now defaulting to false, meaning properties with default values will be omitted from the serialized output unless explicitly enabled.

formats/protobuf/commonMain/src/kotlinx/serialization/protobuf · high confidence

ProtoBuf internal implementation refactored and stabilized

The internal implementation of the ProtoBuf format has been restructured to improve maintainability and support advanced features. This change introduces dedicated internal classes for handling packed arrays (PackedArrayEncoder/Decoder), oneof declarations, and unknown field preservation. It also adds validation to prohibit zero and negative field numbers, fixes encoding for Kotlin unsigned types and negative enums, and ensures empty packed collections are skipped during encoding. These updates refine how the library reads and writes binary data, enhancing compatibility with the Protocol Buffers specification.

formats/protobuf/commonMain/src/kotlinx/serialization/protobuf/internal · high confidence

Refactored polymorphic module registration with separate default serializers and deserializers

The polymorphic module builder now distinguishes between default serializers (for serialization) and default deserializers (for deserialization), replacing the previous single 'default' method with explicit 'polymorphicDefaultSerializer' and 'polymorphicDefaultDeserializer' APIs. This change allows users to provide fallback handling for both directions independently, improving support for unknown types during both serialization and deserialization. The 'default' method is deprecated in favor of 'polymorphicDefaultDeserializer' to maintain backward compatibility while encouraging clearer intent. Additionally, the 'subclassesOfSealed' function is available to automatically register sealed class hierarchies, and the 'overwriteWith' operator enables merging modules with conflict resolution.

core/commonMain/src/kotlinx/serialization/modules · high confidence

Rename Serializers.kt to SerializersJs.kt for JS per-file compilation

The serialization module for the JS target has renamed its source file from Serializers.kt to SerializersJs.kt. This change supports JS per-file compilation requirements, ensuring that the file structure aligns with the platform-specific build configuration without altering the underlying SerializableWith annotation logic.

core/jsMain/src/kotlinx/serialization · high confidence

Serialization core library restructured into new package layout with stabilized annotations

The kotlinx.serialization core module has been reorganized, moving key components like annotations, serializers, and formats into the \core/commonMain/src/kotlinx/serialization\ directory. This change stabilizes several previously experimental annotations, including \@Serializable\, \@SerialName\, \@Required\, \@Transient\, and \@EncodeDefault\, removing the need for opt-in annotations in most standard use cases. The library also introduces new API level markers like \@ExperimentalSerializationApi\ and \@InternalSerializationApi\ to better manage stability guarantees, while retaining core interfaces such as \KSerializer\, \SerialFormat\, and polymorphic serializers like \PolymorphicSerializer\ and \SealedClassSerializer\ in this central location.

core/commonMain/src/kotlinx/serialization · high confidence

Stabilized HOCON serialization format with new encoder/decoder interfaces

The HOCON format support is now stabilized under the \kotlinx.serialization.hocon\ package, replacing the previous \ConfigParser\ naming. Users can now utilize the new \Hocon\ serial format along with dedicated \HoconEncoder\ and \HoconDecoder\ interfaces for serialization and deserialization. The API includes a builder for configuration options such as class discriminators and polymorphism handling, and provides built-in serializers for \ConfigMemorySize\ and \JavaDuration\ types.

formats/hocon · high confidence

Stabilized core serialization API and annotations

The \kotlinx-serialization-core\ module now exposes a stabilized public API surface, including the \@EncodeDefault\ annotation (with \ALWAYS\ and \NEVER\ modes) to control default value encoding, the \@SealedSerializationApi\ annotation for sealed class serialization features, and the \MissingFieldException\ class (now public) which includes a \serialName\ property for better debugging. The \SerialFormat\ interface now exposes \getSerializersModule()\, and built-in serializers for unsigned primitives (\UByte\, \UInt\, \ULong\, \UShort\) and their arrays are available in \BuiltinSerializersKt\. This change formalizes the core contract for serialization strategies, descriptors, and exceptions used across the library.

core/api · high confidence

Support for Pair, Triple, and Collection type resolution via Java Type tokens

The JVM serializer lookup for Java \Type\ tokens now explicitly resolves built-in serializers for \Pair\, \Triple\, and \Collection\ (treating them as \ArrayList\/\List\). This change ensures that generic classes using these types are correctly serialized without requiring explicit contextual registration, improving interoperability for JVM-centric libraries that rely on Java type tokens.

core/jvmMain/src/kotlinx/serialization · high confidence

Thread-local schema caching for Native platforms

The JSON serialization library now uses a thread-local map to store schema caches for custom JSON instances on Native platforms. This change ensures thread safety by preventing shared mutable state between workers, replacing the previous approach where each instance might have had its own cache member. The implementation uses weak references to avoid memory leaks when JSON instances are no longer in use, with periodic cleanup of dead references.

formats/json/nativeMain/src/kotlinx/serialization/json · high confidence

Updated Okio Dokka package list for HTML v1 format

The \okio.package-list\ file in the \formats/json-okio/dokka\ directory has been updated to reflect the \html-v1\ Dokka format. This change ensures that the generated documentation links and metadata for Okio classes (such as \Buffer\, \BufferedSink\, and \BufferedSource\) are correctly aligned with the HTML v1 output structure, supporting the migration to Dokka Gradle Plugin v2.

formats/json-okio/dokka · medium confidence

Updated ProGuard and R8 rules for kotlinx-serialization compatibility

The library now includes specific obfuscation rules to prevent runtime errors in Android environments using R8 full mode or ProGuard. These changes ensure that \INSTANCE\ fields and \serializer()\ functions for serializable objects are preserved, preventing \VerifyError\ and incorrect bytecode generation. Additionally, the rules maintain runtime annotations required for polymorphic serialization and suppress warnings related to \java.lang.ClassValue\ caching.

rules · high confidence

kotlinx.serialization 1.12.0-RC release notes and documentation update

The 1.12.0-RC release candidate introduces API stabilization for core components like \@KeepGeneratedSerializer\, \@SerialInfo\, \JsonNamingStrategy\, and \ContextualSerializer\, alongside performance enhancements for ASCII parsing and large string handling. It also brings significant improvements to exception handling by wrapping deserialization errors in \JsonException\, adds Protobuf support for unknown fields, and updates the library to be based on Kotlin 2.4.10.

(repo-wide) · high confidence

Test coverage

Added JS platform detection test utility; Added JS platform test infrastructure for Protobuf serialization; Added JS-specific tests for dynamic JSON serialization; Added JSON test resources for corner cases and spec compliance; Added JVM platform detection test utility; Added JVM test coverage for BigDecimal, Java collections, and serializer caching; Added JVM tests for JSON compatibility, chunked decoding, concurrency, and error handling; Added JVM tests for ProtoBuf serialization compatibility and behavior; Added JVM-specific CBOR test suite; Added JVM-specific serialization tests for contextual, inheritance, streaming, and type resolution; Added JVM-specific test utilities for serialization tests; Added Proto3 conformance tests for enums, maps, messages, oneofs, and repeated fields; Added automated tests for the Kotlin Serialization guide examples; Added comprehensive test coverage for JSON serializer components; Added comprehensive test coverage for serialization core behaviors; Added integration tests for R8 code shrinking and obfuscation; Added native platform detection test file; Added native platform tests for JSON serialization; Added platform detection test for Kotlin/Native; Added platform detection utilities for WASM support in tests; Added protobuf test schemas for proto2 and proto3; Added test coverage for HOCON serialization features; Added test infrastructure and utilities for JSON serialization; Added test infrastructure for compiler version checks and platform detection; Added test infrastructure for the WASM target; Added test suite for Protobuf schema generation; Added test utilities and data for CBOR serialization tests; Added test utilities for Protobuf serialization; Added tests for JSON I/O and Okio integration; Added tests for JSON escape marker validation; Added tests for JSON serialization edge cases and error handling; Added tests for Properties format serialization capabilities; Added tests for ProtoBuf serialization edge cases and validation; Added tests for Protobuf schema generation edge cases and validations; Added tests for built-in serializers and serial name collision handling; Added tests for contextual serialization of generic classes and module builder behavior; Added tests for inline classes and unsigned integer serialization; Added tests for sequential decoding behavior; Added tests for serialization schema descriptors and sealed interfaces; CBOR format tests migrated to new module structure; Expanded JVM-specific serialization test coverage; Expanded test coverage for JSON polymorphic serialization modes and structures; Expanded test coverage for JSON serialization behaviors; Integration test suite now covers Wasm (JS and WASI) targets; New JSON feature tests for comments, case-insensitive enums, naming strategies, and polymorphism; New benchmark suite for CBOR, JSON, and Moshi performance; Support for sealed interfaces and inline value classes in JSON serialization.

Dependencies

Gradle wrapper upgraded to version 8.7 with enhanced security and reliability

The project's Gradle wrapper has been updated from version 3.5 to 8.7. This upgrade includes a new distribution URL pointing to a JetBrains cache redirector for faster downloads, enables SHA-256 checksum validation for the Gradle distribution to ensure integrity, and adds a network timeout configuration. Users will benefit from the latest Gradle features, improved build performance, and stronger security guarantees during the download and verification process.

gradle · high confidence

Upgrade to Kotlin 2.4 and update build tooling dependencies

The project has upgraded its Kotlin compiler version to 2.4.10, as defined in the central version catalog (gradle/libs.versions.toml). This update is accompanied by upgrades to several build and testing dependencies, including JMH Core to 1.37, the Binary Compatibility Validator to 0.18.1, Dokka to 2.2.0-Beta, and the Gradle Shadow plugin to 8.3.9. The core runtime library now requires Kotlin 2.0.0-RC1 or later, and the integration tests have been configured to run native tests in release mode.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 42 → 54 (+12.3)
  • Rubric changed (rubric-2026.08.15 → rubric-2026.09.15) — scores are not directly comparable.

Lenses

  • Code Health 96 → 93 (-3.2)
  • Architecture 94 → 100 (+5.4)
  • Maturity 50 → 56 (+6.2)
  • Readiness 17 → 36 (+19.5)
  • Security 65 → 75 (+9.8)

Resolved (25)

  • Coverage not measured — test suite did not build
  • Dimension evaluation failed
  • Duplicated block (10 lines × 2) (core/jsMain/src/kotlinx/serialization/internal/Platform.kt)
  • Duplicated block (13 lines × 2) (formats/json/commonMain/src/kotlinx/serialization/json/internal/StreamingJsonEncoder.kt)
  • Duplicated block (14 lines × 2) (core/jsMain/src/kotlinx/serialization/internal/Platform.kt)
  • Duplicated block (14 lines × 2) (formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/CommentLexers.kt)
  • High CVE: [GHSA redacted] (integration-test/kotlin-js-store/yarn.lock)
  • High CVE: [GHSA redacted] (integration-test/kotlin-js-store/yarn.lock)
  • High CVE: [GHSA redacted] (integration-test/kotlin-js-store/yarn.lock)
  • High CVE: [GHSA redacted] (integration-test/kotlin-js-store/yarn.lock)
  • High CVE: [GHSA redacted] (integration-test/kotlin-js-store/yarn.lock)
  • High CVE: [GHSA redacted] (integration-test/kotlin-js-store/yarn.lock)
  • High CVE: [GHSA redacted] (integration-test/kotlin-js-store/yarn.lock)
  • High CVE: [GHSA redacted] (integration-test/kotlin-js-store/yarn.lock)
  • High CVE: [GHSA redacted] (integration-test/kotlin-js-store/yarn.lock)
  • High CVE: [GHSA redacted] (integration-test/kotlin-js-store/yarn.lock)
  • Low CVE: [GHSA redacted] (integration-test/kotlin-js-store/yarn.lock)
  • Low CVE: [GHSA redacted] (integration-test/kotlin-js-store/yarn.lock)
  • Medium CVE: [GHSA redacted] (integration-test/kotlin-js-store/yarn.lock)
  • Medium CVE: [GHSA redacted] (integration-test/kotlin-js-store/yarn.lock)
  • …and 5 more

New (64)

  • AbstractJsonLexer.consumeNumericLiteral (cognitive 55) (formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/AbstractJsonLexer.kt)
  • AbstractJsonLexer.consumeNumericLiteral (cyclomatic 36) (formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/AbstractJsonLexer.kt)
  • AbstractJsonLexer.skipElement (cognitive 18) (formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/AbstractJsonLexer.kt)
  • BufferedJsonLexerWithComments.handleComment (cognitive 17) (formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/CommentLexers.kt)
  • CborParser.skipElement (cognitive 20) (formats/cbor/commonMain/src/kotlinx/serialization/cbor/internal/Decoder.kt)
  • CharsetReader.doRead (cognitive 22) (formats/json/jvmMain/src/kotlinx/serialization/json/internal/CharsetReader.kt)
  • Dependency hygiene PARTLY measured — Maven/Gradle declarations read, no dependency graph resolved
  • Documentation: no installation or build instructions (docs/building.md)
  • Duplicated block (11–12 lines × 2) (formats/json/commonMain/src/kotlinx/serialization/json/internal/lexer/CommentLexers.kt)
  • Duplicated block (13 lines × 2) (formats/json-io/commonMain/src/kotlinx/serialization/json/io/internal/IoJsonStreams.kt)
  • Duplicated block (32 lines × 3) (core/jsMain/src/kotlinx/serialization/internal/Platform.kt)
  • Duplicated block (7 lines × 3) (core/jsMain/src/kotlinx/serialization/internal/Platform.kt)
  • Duplicated block (7 lines × 3) (core/jsMain/src/kotlinx/serialization/internal/Platform.kt)
  • Duplicated block (8 lines × 2) (formats/cbor/commonMain/src/kotlinx/serialization/cbor/internal/Streams.kt)
  • Duplicated block (8 lines × 3) (formats/protobuf/jsMain/src/kotlinx/serialization/protobuf/internal/Bytes.kt)
  • FixmeComment (formats/json-tests/commonTest/src/kotlinx/serialization/features/LocalClassesTest.kt)
  • FixmeComment (formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonDecodingErrorMessagesTest.kt)
  • FixmeComment (formats/protobuf/jvmTest/src/kotlinx/serialization/protobuf/schema/GenerationTest.kt)
  • Further sole-owners (lower concentration)
  • High CVE: [GHSA redacted] (kotlin-js-store/yarn.lock)
  • …and 44 more

Changes since last survey

  • 24 commits — 23 feature/other, 1 fixes

By area

  • formats/json — 8 commits
  • buildSrc/src — 5 commits
  • formats/json-tests — 3 commits
  • formats/protobuf — 3 commits
  • core/commonMain — 2 commits
  • (repo) — 1 commit
  • (root) — 1 commit
  • formats/cbor — 1 commit

Notable commits

  • fix: Fixed of Protobuf schema generation for inlined value classes (#3209)
  • change: Add Json nesting depth calculation during parsing
  • change: Add exception handling to decodeSerializableValue in Json decoders
  • change: Add exception handling to encodeSerializableValue in Json encoders
  • change: Avoid specifying -Xjdk-release twice (#3247)
  • change: Bring back @Experimental on @JsonNames (#3254)
  • change: Deprecate ChunkedDecoder (#3238)
  • change: Get rid of old Kotlin version checks (#3241)
  • change: Included G Play SDK verification files for published modules (#3208)
  • change: Increase stack size for mingwx64 test binaries
  • change: JsonElementBuilders: mark all (add|put)Json(Object|Array) functions as inline (#3242)
  • change: Merge remote-tracking branch 'origin/master' into dev
  • change: Prepare 1.12.0-RC (#3258)
  • change: Rewrite TreeJsonDecoder main decoding loop to be identical to StreamingJsonDecoder (#3220)
  • change: Set Deprecated(HIDDEN) to setters in JsonConfiguration
  • change: Simplify try-catching during polymorphic Json operations.
  • change: Stabilize @SerialInfo and its Json annotations (#3239)
  • change: Stop unconditionally dumping serialized data from protobuf tests (#3240)
  • change: Support preserving unknown fields in ProtoBuf format (#2860)
  • change: Update JsonPath tests:
  • …and 4 more

Architecture

  • Containers 0 added · 0 removed · contexts 10 added · 0 removed · edges 12 added · 0 removed

Added bounded contexts (10)

  • benchmark
  • cbor
  • core
  • guide
  • hocon
  • integration-test
  • json
  • properties
  • protobuf
  • rules-integration-tests

Added dependency edges (12)

  • benchmark → cbor
  • benchmark → core
  • benchmark → json
  • cbor → core (coupling)
  • guide → core (coupling)
  • guide → json
  • guide → protobuf
  • hocon → core (coupling)
  • integration-test → core (coupling)
  • json → core (coupling)
  • properties → core (coupling)
  • protobuf → core (coupling)

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

Kotlin/kotlinx.serialization was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 25 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 397bb560096fcb7b2a9363741690cca3d28124ba — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-dd72cc24c749.