KSUID Generator & Decoder
Generate cryptographically random KSUIDs, decode their timestamps and payloads, or compose a deterministic 20-byte ID in Base62 or hex.
Timestamp and random payload
A KSUID contains a 4-byte big-endian timestamp and 16 random bytes. Its epoch is Unix second 1400000000, or 2014-05-13T16:53:20Z. The fixed 27-character text uses the Base62 alphabet 0–9, A–Z, a–z. Letter case is significant; values exceeding the 160-bit format are rejected.
Generate or reproduce fixtures
Generate creates 1–1,000 fresh payloads with crypto.getRandomValues and the selected UTC second. Compose accepts exactly 16 bytes of hexadecimal payload for deterministic fixtures. Decode accepts Base62 or 40 hexadecimal digits and reports both forms without losing leading zero bytes.
Sorting and limits
KSUIDs sort approximately by timestamp when compared with the stated case-sensitive alphabet. IDs created within one second sort by their random payload, not creation order. Timestamp generation is restricted to the unsigned 32-bit offset range. IDs are not authentication secrets, proof of identity or a replacement for database uniqueness constraints.
Questions & answers
Does a decoded time prove when a record was created?
A KSUID stores seconds relative to its own epoch. A composed ID can include a supplied timestamp, so the decoded value identifies the field’s contents rather than verifying an event time.
Are inputs uploaded or saved?
No. The tool runs locally in a Web Worker and does not send IDs to an API or save them in local storage. Copy and Download use the current result; edits or cancellation discard stale output.
Other Languages
References
How we make sure
We check this tool with the automated test suites linked below. Example checks are shown in their original language.
- Verification method
- Check encoded fields, integer precision, alphabets and boundaries using fixed IDs/timestamps, plus applicable monotonic generation.
- Comparison reference
- Fixed field/timestamp fixtures for each format; Snowflake includes a published Discord vector.
- Verification scope
- Field and finite-sample checks do not guarantee collision-free random IDs.
Test source and cases (select a file to read it)
-
identifier-tools.test.js
- Discord documented Snowflake vector and exact composition
- Snowflake all bit fields preserve integers above 2^53 and full uint64 Discord range
These checks cover the listed examples and boundaries, not every possible input. Round trips and checks using the same library are not independent verification.