ULID Logo

What is a ULID?

A ULID (Universally Unique Lexicographically Sortable Identifier) is a 128-bit unique identifier encoded as a 26-character string. Unlike a random UUID, a ULID starts with a timestamp, so sorting ULIDs alphabetically also sorts them by creation time.

01ARZ3NDEKTSV4RRFFQ69G5FAV
Timestamp: 10 chars, 48 bits, milliseconds since Unix epoch
Randomness: 16 chars, 80 bits

The 48-bit timestamp is valid until the year 10889, and the 80 bits of randomness allow for 1.21 × 1024 unique ULIDs per millisecond. The encoding is Crockford base32: digits 0-9 and letters A-Z, excluding I, L, O and U to avoid misreading. ULIDs are case-insensitive, URL-safe and contain no special characters. The format is defined by the ULID specification.

ULID vs UUID v4 vs UUID v7

ULIDUUID v4UUID v7
Size128 bits128 bits128 bits
Text format26 chars, Crockford base3236 chars, hex with hyphens36 chars, hex with hyphens
Sortable by timeYes - lexicographic order is chronologicalNo - fully randomYes - lexicographic order is chronological
Embedded timestamp48-bit, millisecond precisionNone48-bit, millisecond precision
Random bits8012274
Database index localitySequential insertsRandom inserts (index fragmentation)Sequential inserts
Case-insensitiveYesYes (hex)Yes (hex)

UUID v4 and v7 are defined in RFC 9562. ULID predates UUID v7 and solves the same problem - time-ordered unique IDs - with a shorter, URL-friendly encoding.