kotlinx.serialization

Official Kotlin serialization library by JetBrains. Uses a Kotlin compiler plugin to generate serializers at compile time for @Serializable classes. Supports JSON, Protobuf, CBOR, and custom formats. Works across Kotlin Multiplatform (JVM, JS, Native). No reflection required — serializers generated at compile time.

Evaluated Mar 06, 2026 (0d ago) v1.6+
Homepage ↗ Repo ↗ Developer Tools kotlin serialization json multiplatform protobuf cbor compiler-plugin kmm
⚙ Agent Friendliness
68
/ 100
Can an agent use this?
🔒 Security
97
/ 100
Is it safe for agents?
⚡ Reliability
86
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
88
Error Messages
82
Auth Simplicity
100
Rate Limits
100

🔒 Security

TLS Enforcement
100
Auth Strength
100
Scope Granularity
100
Dep. Hygiene
90
Secret Handling
92

Compile-time code generation — no reflection, no runtime bytecode manipulation. No security concerns beyond input validation in custom serializers.

⚡ Reliability

Uptime/SLA
95
Version Stability
82
Breaking Changes
78
Error Recovery
88
AF Security Reliability

Best When

Building Kotlin or Kotlin Multiplatform applications that need compile-time safe, reflection-free serialization.

Avoid When

You need XML support, Java interop with Jackson annotations, or are working in a pure Java codebase.

Use Cases

  • Serialize/deserialize Kotlin data classes to/from JSON in Ktor, Spring Kotlin, or KMM applications with @Serializable annotation
  • Build Kotlin Multiplatform (KMM) models with shared serialization logic across Android, iOS, and backend targets
  • Encode Kotlin objects to Protobuf or CBOR for compact binary serialization in performance-sensitive applications
  • Implement custom serializers for types that can't be annotated (third-party classes) using KSerializer<T>
  • Handle JSON polymorphism with sealed classes using @SerialName annotations for type discriminators

Not For

  • POJO serialization from Java code — kotlinx.serialization requires Kotlin with the compiler plugin; use Jackson or Gson for pure Java
  • XML serialization — kotlinx.serialization doesn't include an XML format; use kotlin-xml-builder or Jsoup for XML
  • Dynamic/untyped JSON manipulation — for ad-hoc JSON manipulation without type classes, use kotlinx.serialization's JsonElement API or consider a JSON library

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

Library — no auth needed.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

JetBrains open source library.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • Requires the Kotlin serialization Gradle plugin (kotlin('plugin.serialization')) — forgetting this causes confusing 'Serializer not found' errors at runtime
  • All serialized classes must be annotated with @Serializable — third-party classes require custom KSerializer implementations
  • Default JSON configuration is strict — unknown keys throw exceptions unless Json { ignoreUnknownKeys = true } is configured
  • Polymorphism requires explicit registration with SerializersModule — sealed classes work out of the box but open class hierarchies need manual configuration
  • Kotlin's default parameter values don't automatically become JSON defaults — use @Required or handle missing fields explicitly
  • v1.5+ changed the encodeDefaults behavior — previously fields with default values were omitted by default, now they're included; check Json configuration when migrating

Alternatives

Full Evaluation Report

Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for kotlinx.serialization.

$99

Scores are editorial opinions as of 2026-03-06.

5215
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered