ULID Generator
Generate Universally Unique Lexicographically Sortable Identifiers
ULID Generator
Generate Universally Unique Lexicographically Sortable Identifiers
About ULID Generator
Generate Universally Unique Lexicographically Sortable Identifiers (ULID) for modern applications. ULID combines the uniqueness of UUIDs with lexicographic sortability and improved performance characteristics.
- 128-bit compatibility with UUID
- Lexicographically sortable by timestamp
- Canonically encoded as 26-character strings
- Case insensitive and URL safe
- Monotonic sort order within same millisecond
How to Use ULID Generator
- Generate Single ULID - Click generate to create one unique identifier
- Bulk Generation - Specify quantity for multiple ULIDs at once
- Custom Timestamp - Optionally specify a custom timestamp
- Copy Results - Easily copy generated ULIDs to clipboard
- Validate Format - Verify existing ULID format and structure
Frequently Asked Questions
What is ULID used for?
ULID is used as a primary key in databases, event IDs in distributed systems, correlation IDs in microservices, and anywhere you need unique identifiers that sort chronologically. Its time-ordered nature improves B-tree index locality, reducing page splits and boosting read/write performance.
ULID vs UUID which is better?
ULID is better when you need sortable IDs, compact representation (26 chars vs 36), and better database index performance. UUID is better for maximum ecosystem compatibility. UUID v7 (RFC 9562) is a newer standard that brings time-ordering to UUIDs, narrowing the gap. Choose ULID for greenfield projects needing sort order.
How to generate ULID in Node.js?
Install the ulid package: npm install ulid, then use: import { ulid, monotonicFactory } from 'ulid'; const id = ulid(); For monotonic ordering: const monotonic = monotonicFactory(); const id1 = monotonic(); const id2 = monotonic(); -- guaranteed id2 > id1.
Is ULID URL safe?
Yes. ULID uses Crockford's Base32 encoding which only contains characters 0-9 and A-Z (excluding I, L, O, U to avoid ambiguity). It's case-insensitive, contains no special characters, and is safe for URLs, filenames, HTML attributes, and CSS selectors without encoding.
How to decode timestamp from ULID?
The first 10 characters of a ULID encode a 48-bit Unix timestamp in milliseconds using Crockford's Base32. Decode by converting those 10 chars from Base32 to a number, then create a Date: new Date(decodedTimestamp). utilAZ shows the decoded timestamp automatically.
ULID vs UUID performance comparison?
ULIDs outperform random UUIDs (v4) in database writes by 20-40% due to sequential B-tree inserts instead of random page splits. Read performance also improves because recent records cluster together. UUID v7 offers similar benefits. Generation speed is comparable (~1M/sec in JS for both).
Common Use Cases
- Database primary keys and indexes
- Distributed system identifiers
- Event sourcing and logging
- API request/response tracking
- File and document naming
- Session and transaction IDs
- Microservice correlation IDs
- Time-series data organization
Technical Specifications
ULID Structure:
- Total Length: 128 bits (same as UUID)
- Timestamp: 48 bits (Unix timestamp in milliseconds)
- Randomness: 80 bits (cryptographically strong random data)
- Encoding: Crockford Base32 (26 characters)
- Character Set: 0123456789ABCDEFGHJKMNPQRSTVWXYZ
ULID vs UUID Comparison
| Feature | ULID | UUID v4 | UUID v1 |
|---|---|---|---|
| Length | 26 chars | 36 chars | 36 chars |
| Sortable | ✅ Yes | ❌ No | ⚠️ Partially |
| URL Safe | ✅ Yes | ❌ No | ❌ No |
| Case Insensitive | ✅ Yes | ❌ No | ❌ No |
| Timestamp Embedded | ✅ Yes | ❌ No | ✅ Yes |
How ULID Generation Works
A ULID combines a 48-bit Unix timestamp in milliseconds (the first 10 characters) with 80 bits of cryptographically secure randomness (the remaining 16 characters), all encoded in Crockford's Base32. This structure ensures that ULIDs generated at the same millisecond are still unique while remaining lexicographically sortable by creation time.
Quick Examples
// JavaScript / Node.js
const { ulid } = require('ulid');
const id = ulid(); // e.g. 01AN4Z07BY79KA1307SR9X4MV3
# Python
from ulid import ULID
id = str(ULID()) # e.g. 01AN4Z07BY79KA1307SR9X4MV3
The tool above generates ULIDs directly in your browser, lets you create them in bulk, and extracts the embedded timestamp so you can inspect when each identifier was created.
