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.

text
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.

PropertyULIDUUID v7
Length26 characters36 characters with hyphens
AlphabetCrockford base32Hexadecimal
Timestamp48-bit ms48-bit ms
Random bits8074 (plus variant bits)
CaseUppercase by conventionLowercase by convention
StandardCommunity specRFC 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.