← All tools

KSUID Generator & Decoder

Generate and decode KSUIDs (K-Sortable Unique IDs), the identifier format popularized by Segment. A KSUID is a 27-character base62 string encoding a 160-bit value: a 32-bit timestamp (seconds since a 2014 epoch, so KSUIDs sort chronologically) followed by a 128-bit random payload — enough randomness that collisions are negligible. Everything runs locally in your browser; randomness comes from the Web Crypto API.

Generate

Decode

KSUID

KSUID packs 160 bits into 27 base62 characters (0–9 A–Z a–z): the first 32 bits are a timestamp stored as seconds since the custom epoch 1400000000 (2014-05-13 UTC, giving ~136 years of range), and the remaining 128 bits are a random payload. Because the timestamp leads, sorting KSUIDs as strings sorts them by creation time. The whole 160-bit value is converted to base62 with BigInt arithmetic and left-padded with 0 to exactly 27 characters (since 62²⁷ > 2¹⁶⁰, every value fits). Decoding reverses this: parse the base62 string back to a 160-bit BigInt, split into the 4-byte timestamp and 16-byte payload, and add the epoch back to get a wall-clock time. Pairs with the UUID, ULID, Snowflake, and NanoID generators. Everything runs locally — nothing leaves your browser.