KSUID Generator
Generate KSUIDs (K-Sortable Unique Identifiers) — 27-character, Base62, naturally time-sortable IDs with a 4-byte timestamp and 16 bytes of cryptographically-random payload. Batch-generate, pin the timestamp, or supply a fixed payload for reproducible output, all in your browser.
Input
Ignored when a fixed payload is supplied below (a fixed payload yields exactly one KSUID).
The instant encoded in the KSUID's first 4 bytes. Enter Unix seconds (e.g. 1507608047) or an ISO 8601 date (e.g. 2017-10-10T04:00:47Z). Leave blank to use the current time.
Optional. Supply exactly 32 hex characters (16 bytes) to use a fixed payload instead of cryptographically-random bytes — useful for reproducible, verifiable output. Leave blank for secure random payloads.
Output
One 27-character KSUID per line.
Guides
What is a KSUID?
A KSUID (K-Sortable Unique Identifier) is a globally unique ID designed by Segment that you can sort chronologically without a separate timestamp column. Each KSUID packs 20 bytes into a compact, URL-safe, 27-character string: a 4-byte timestamp followed by 16 bytes of cryptographically-random payload. That's 128 bits of randomness — collision-resistant enough for high-volume distributed systems — combined with a built-in creation time.
The timestamp counts seconds from a custom KSUID epoch of 2014-05-13T16:53:20Z (Unix time 1,400,000,000), not the Unix epoch. Shifting the origin forward buys roughly 136 years of range from just four bytes, so KSUIDs stay valid until around the year 2150.
This generator builds real, standards-conformant KSUIDs entirely in your browser and lets you batch-generate them, pin the timestamp, or supply a fixed payload for reproducible output.
How to use it
- Set How many to generate to produce a batch of KSUIDs at once (1–50).
- Optionally set a Timestamp — enter Unix seconds (e.g.
1507608047) or an ISO 8601 date (e.g.2017-10-10T04:00:47Z). Leave it blank to stamp them with the current time. - Optionally supply a Fixed payload (32 hex characters) when you need a specific, reproducible KSUID — for example, to reproduce a known value in a test. With a fixed payload the tool emits exactly one KSUID.
- Click Generate, then copy or download the results (one KSUID per line).
Why KSUIDs are "K-sortable"
The 20 raw bytes are treated as a single 160-bit number and encoded in Base62 (digits 0-9, then A-Z, then a-z), left-padded with zeros to exactly 27 characters. Because the timestamp occupies the most-significant bytes, the lexicographic order of the Base62 strings matches the chronological order of creation. In other words, plain alphabetical string sorting — in a database index, a filename listing, or a sort command — also sorts your IDs by time. That's the "K" (K-sortable) in KSUID, and it's what makes them so convenient as primary keys.
How is a KSUID different from a UUID?
A UUIDv4 is entirely random and carries no time information, so it can't be sorted meaningfully and fragments database indexes. A KSUID embeds its creation time in the high-order bytes, so it sorts by time and clusters nicely in B-tree indexes, while still carrying 128 bits of randomness.
Are these KSUIDs safe to use in production?
Yes. The 16-byte payload comes from the Web Crypto CSPRNG (crypto.getRandomValues), the same secure source used by real KSUID libraries, and the encoding matches the reference implementation byte-for-byte.
Can I decode a KSUID back to its timestamp?
The first four Base62-decoded bytes are the seconds-since-KSUID-epoch timestamp; add 1,400,000,000 to get a normal Unix time. This tool focuses on generation, but the structure is fully reversible.
Why does a fixed payload only produce one KSUID?
A fixed payload with a fixed timestamp is fully deterministic, so a batch would just repeat the same string. The fixed-payload mode is meant for reproducing one exact, verifiable value.
Privacy
Everything runs entirely client-side, in your browser. Your timestamps and generated IDs are never uploaded, logged, or sent to a server — the random bytes are drawn locally from your device's secure random number generator.