kencode

kencode

Used in: combo.

Kencode packs typed data classes into short, URL-safe strings. The use case is the kind of state that has to ride inside a character-limited surface (a query string, a deeplink, a Discord message, a printed coupon) where JSON is too verbose and an opaque ID forces a database round-trip. A serializable data class becomes a compact token in one call and decodes back to the same typed shape on the other side.

The library is layered: a binary format produces compact byte payloads, an optional payload transform applies checksums or strips leading zeros, and a text codec encodes the bytes as ASCII. PackedFormat and Base62 are the defaults; ProtoBuf is available when cross-language compatibility matters. The binary side is built on kotlinx.serialization and walks the serial descriptor directly, so optimizations like grouping booleans into a bitfield, varint-encoding small numbers, and skipping intermediate trees fall out of the schema rather than ad-hoc per-type code. Payload transforms compose freely, so the same pipeline supports checksums, encryption, or error-correcting codes without changing the surface API.

Install

dependencies {
  implementation("com.eignex:kencode:1.3.0")
}

Where to go next