Structure
The first 48 bits are a Unix millisecond timestamp, encoded in 10 base32 characters. The remaining 80 bits are random, encoded in 16 characters. The alphabet is Crockford base32: digits and uppercase letters excluding I, L, O and U to avoid confusion.
01JC8Z6Q9M7XK3V2B5N8R4T6WY
^^^^^^^^^^ ^^^^^^^^^^^^^^^^
timestamp 80 random bits
(10 chars)
ULID vs UUID
Both are time-sortable and database-friendly. ULID is shorter, which helps in URLs and logs; UUID v7 is an IETF standard with wider library support. Choose based on ecosystem, not on the encoding.
| Property | ULID | UUID v7 |
|---|---|---|
| Length | 26 characters | 36 characters with hyphens |
| Alphabet | Crockford base32 | Hexadecimal |
| Timestamp | 48-bit ms | 48-bit ms |
| Random bits | 80 | 74 (plus variant bits) |
| Case | Uppercase by convention | Lowercase by convention |
| Standard | Community spec | RFC 9562 |
Sorting rules
Lexicographic sorting works because the timestamp is the high-order prefix and the alphabet is fixed-width. The format is case-insensitive for parsing but should be stored uppercase; mixed case breaks byte-wise comparison.
The 48-bit timestamp overflows in the year 10889. Like all millisecond-based IDs, it is not a concern for application lifetimes.