A ULID is a 128-bit lexicographically sortable, URL-safe identifier encoded in 26 Crockford Base32 characters with millisecond timestamp precision.
A Universally Unique Lexicographically Sortable Identifier (ULID) is a standardized 128-bit (16-byte) identifier specification designed to provide time-ordered sorting, high-entropy uniqueness, and compact URL-safe string representations without central coordination.
Generate, inspect, and validate ULIDs, UUID v4, and UUID v7 in bulk with our client-side UUID Generator tool.
A canonical ULID is rendered as a 26-character string using Douglas Crockford's Base32 alphabet (0123456789ABCDEFGHJKMNPQRSTVWXYZ):
01AN4Z07BY 79KA1307SR9X4MV3
|----------| |----------------|
Timestamp Randomness
(10 chars) (16 chars)
48 bits 80 bits
crypto.getRandomValues().ULID utilizes Crockford's Base32 encoding to maximize readability, prevent visual transcription errors, and ensure case-insensitivity:
I, L, O, and U are excluded to prevent visual ambiguity with numbers 1, 0, and accidental profanity.-, _, /, +), making ULIDs directly embeddable in URL paths, query parameters, HTML attributes, and JSON payloads without URL-encoding.| Feature | ULID | UUID v7 (RFC 9562) | UUID v4 |
|---|---|---|---|
| Bit Depth | 128 bits | 128 bits | 128 bits |
| String Length | 26 characters | 36 characters | 36 characters |
| Encoding | Crockford Base32 | Hexadecimal with dashes | Hexadecimal with dashes |
| Time-Sortable | Yes (Lexicographical) | Yes (B-Tree friendly) | No (Random) |
| Timestamp Precision | Millisecond (48-bit) | Millisecond (48-bit) | None |
| Random Entropy | 80 bits | 74 bits | 122 bits |
| Database Binary Size | 16 bytes | 16 bytes | 16 bytes |
| IETF Standard | Community Standard | IETF RFC 9562 (2024) | IETF RFC 9562 / 4122 |
Like UUID v7, ULIDs eliminate the severe index fragmentation issues associated with random UUID v4:
UUID or MySQL BINARY(16) columns.// Crockford Base32 alphabet
const ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
export function generateUlid(timestamp = Date.now()): string {
// 1. Encode 48-bit timestamp (10 chars)
let timeStr = "";
let t = timestamp;
for (let i = 9; i >= 0; i--) {
timeStr = ENCODING[t % 32] + timeStr;
t = Math.floor(t / 32);
}
// 2. Generate 80 bits of random entropy (16 chars)
const randBytes = new Uint8Array(10);
crypto.getRandomValues(randBytes);
let randStr = "";
const bits = Array.from(randBytes).flatMap(b =>
[7, 6, 5, 4, 3, 2, 1, 0].map(bit => (b >> bit) & 1)
);
for (let i = 0; i < 16; i++) {
let val = 0;
for (let j = 0; j < 5; j++) {
val = (val << 1) | (bits[i * 5 + j] ?? 0);
}
randStr += ENCODING[val];
}
return timeStr + randStr;
}
import time
import os
CROCKFORD_BASE32 = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"
def generate_ulid() -> str:
# 48-bit millisecond timestamp
t = int(time.time() * 1000)
time_chars = []
for _ in range(10):
time_chars.append(CROCKFORD_BASE32[t % 32])
t //= 32
time_str = "".join(reversed(time_chars))
# 80-bit random component (10 bytes -> 16 chars)
rand_bytes = os.urandom(10)
rand_int = int.from_bytes(rand_bytes, byteorder="big")
rand_chars = []
for _ in range(16):
rand_chars.append(CROCKFORD_BASE32[rand_int % 32])
rand_int //= 32
rand_str = "".join(reversed(rand_chars))
return time_str + rand_str
Yes. Both ULID and UUID are 128-bit binary numbers. A 26-character Crockford Base32 ULID can be unpacked into a 16-byte binary buffer and reformatted as a 36-character hexadecimal UUID string (8-4-4-4-12), and vice versa, preserving the underlying timestamp and entropy.
When generated within the same millisecond, ULIDs share the same 10-character timestamp prefix. The 80-bit random suffix provides $2^{80} \approx 1.2 \times 10^{24}$ unique combinations per millisecond. Monotonic ULID implementations increment the random component by 1 to guarantee absolute sort order during sub-millisecond bursts.
No. Crockford Base32 is case-insensitive. Canonical ULIDs are conventionally formatted in uppercase letters (01ARZ3NDEKTSV4RRFFQ69G5FAV), but parsing implementations treat lowercase characters identically (01arz3ndektsv4rrffq69g5fav).
Free, browser-based utilities to test, generate, and inspect Universally Unique Lexicographically Sortable Identifier (ULID) payloads directly.