Developer Tools
ULID Generator - Sortable Unique ID Generator
Generate ULIDs (Universally Unique Lexicographically Sortable Identifiers) in the browser. ULIDs combine a millisecond-precision timestamp with cryptographic randomness into a 26-character Crockford Base32 string.
What is ULID?
ULID (Universally Unique Lexicographically Sortable Identifier) is a 128-bit identifier encoded as a 26-character string. Unlike UUID v4, ULIDs sort in creation order, making them excellent primary keys for databases and distributed logs.
Structure
The first 10 characters encode the Unix timestamp in milliseconds using Crockford Base32
(highlighted in amber). The last 16 characters are 80 bits of cryptographically random data,
generated via crypto.getRandomValues().
ULID vs. UUID comparison
| Property | ULID | UUID v4 | UUID v7 |
|---|---|---|---|
| Sortable by creation time | Yes | No | Yes |
| Timestamp embedded | Yes (ms) | No | Yes (ms) |
| Encoded length | 26 chars | 36 chars | 36 chars |
| Character set | Crockford Base32 | Hex + hyphens | Hex + hyphens |
| Collision probability (80-bit random) | Very low | Very low (122-bit) | Very low (74-bit) |
| B-tree index friendly | Yes | No | Yes |
UUID v7 is a close counterpart to ULID: both embed a millisecond Unix timestamp for sortability. The key difference is encoding - ULID’s Crockford Base32 is URL-safe and case-insensitive, while UUID v7 uses the familiar hex-hyphen format with wider library support.
Database primary key guidance
Because ULIDs sort lexicographically by creation time, new records are always inserted near the end of a B-tree index. This dramatically reduces index page splits and fragmentation compared to random UUIDs, which insert at random positions and force costly page reorganization. In high-write workloads on PostgreSQL or MySQL, switching from UUID v4 to ULID (or UUID v7) can cut index write amplification significantly and improve insert throughput.
Crockford Base32 alphabet
ULID uses Douglas Crockford’s Base32 alphabet, which deliberately excludes four characters:
I, L, O, and U. These are omitted because
they are visually ambiguous with 1, 1, 0, and
V respectively, making handwritten or spoken ULIDs much less error-prone. The resulting
alphabet is 0123456789ABCDEFGHJKMNPQRSTVWXYZ.