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.
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
| ULID | UUID v4 | UUID v7 | |
|---|---|---|---|
| Size | 128 bits | 128 bits | 128 bits |
| Text format | 26 chars, Crockford base32 | 36 chars, hex with hyphens | 36 chars, hex with hyphens |
| Sortable by time | Yes - lexicographic order is chronological | No - fully random | Yes - lexicographic order is chronological |
| Embedded timestamp | 48-bit, millisecond precision | None | 48-bit, millisecond precision |
| Random bits | 80 | 122 | 74 |
| Database index locality | Sequential inserts | Random inserts (index fragmentation) | Sequential inserts |
| Case-insensitive | Yes | Yes (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.
