ULID (Universally Unique Lexicographically Sortable Identifier) is a 128-bit compatible identifier that solves UUID sortability problems. It is 26 characters long, encoded in Crockford's Base32 alphabet, and is completely case-insensitive and URL-safe.
Format Specification
- 10 Characters (48 bits): Unix timestamp in milliseconds with support up to the year 10,889 AD.
- 16 Characters (80 bits): Cryptographically secure random entropy.
- Crockford's Base32: Uses
0123456789ABCDEFGHJKMNPQRSTVWXYZ, deliberately excludingI,L,O, andUto avoid visual confusion and prevent accidental profanity.
Usage
js
import { ulid } from '@readytools/id';
// Generate a new ULID using current timestamp
const id = ulid();
// Returns: "01ARZ3NDEKTSV4RRFFQ69G5FAV"
// Generate a ULID for a specific historical timestamp (in ms)
const pastId = ulid(Date.parse('2024-01-01T00:00:00Z'));
// Returns: "01HM000000..."⚡ Live Playground
ulid()
Generating...
📏 Calculating...✨ Web Crypto Native
Monotonicity in the Same Millisecond
When generating multiple ULIDs within the exact same millisecond timestamp, @readytools/id increments the lowest random bits using Base32 carry math. This guarantees strict chronological sort order (id1 < id2 < id3) even under millions of operations per second.