Introduction
UUIDs have a problem: they are not sortable. If you store UUIDs as database primary keys, your indexes become fragmented because each insert goes to a random position. ULID solves this by encoding a millisecond timestamp in the first 10 characters and random entropy in the remaining 16. The result is a 26-character string that sorts lexicographically by creation time. ULIDs are drop-in replacements for UUIDs in most systems, and they use Crockford Base32 so they are URL-safe and case-insensitive. This generator produces ULIDs using the browser's CSPRNG and can decode the timestamp from any ULID you paste.
What this tool does
- Generates ULIDs (Universally Unique Lexicographically Sortable Identifiers) using crypto.getRandomValues.
- 26-character Crockford Base32 encoding, URL-safe and case-insensitive.
- Bulk generation: produce up to 100 ULIDs at once.
- Paste any ULID to decode its embedded millisecond timestamp.
- All generation happens client-side with no network calls.
How this tool works
The generator follows the ULID specification. It takes the current time in milliseconds since the Unix epoch and encodes it into 10 characters using Crockford Base32 (alphabet: 0123456789ABCDEFGHJKMNPQRSTVWXYZ, excluding I, L, O, U to avoid confusion). The remaining 16 characters are filled with random bytes from crypto.getRandomValues, also encoded in Crockford Base32. The timestamp portion ensures lexicographic sortability: ULIDs generated later always sort after ULIDs generated earlier (within the same millisecond, random order applies). The decoder extracts the first 10 characters and reverses the Base32 encoding to recover the original timestamp.
How ULID encoding works
ULID was created by Aaron Hardick and published as an open specification in 2016. The design combines two goals: uniqueness and sortability.
Structure (26 characters):
| Section | Length | Content | Encoding | |---|---|---|---| | Timestamp | 10 chars | ms since Unix epoch | Crockford Base32 | | Random | 16 chars | CSPRNG output | Crockford Base32 |
Crockford Base32 alphabet: 0123456789ABCDEFGHJKMNPQRSTVWXYZ (32 symbols, excludes I, L, O, U)
The timestamp encodes up to 2^48 milliseconds, which covers dates from 1970 to approximately 10889 AD. The random portion provides 80 bits of entropy, giving 1.2 x 10^24 possible values per millisecond.
Comparison with UUID:
| Property | UUID v4 | ULID | |---|---|---| | Length | 36 chars | 26 chars | | Sortable | No | Yes (by timestamp) | | Entropy | 122 bits | 80 bits (random) + 48 bits (time) | | Encoding | Hex | Crockford Base32 | | URL-safe | No (hyphens) | Yes |
The sortability property is valuable for database indexing. When you use ULIDs as primary keys in B-tree indexes, new inserts append to the end of the index rather than scattering randomly. This reduces page splits and write amplification, which matters for high-throughput insert workloads.
ULIDs generated within the same millisecond are not guaranteed to sort correctly relative to each other because the random portion dominates. For monotonic ordering within a millisecond, use a monotonic ULID factory (not provided by this tool).
How to use this tool
- Set the quantity if you need multiple ULIDs (up to 100).
- Click Generate New ULID to produce fresh identifiers.
- Copy a single ULID or the entire batch using the Copy button.
- To decode a timestamp, paste any ULID into the input field. The decoded ISO timestamp appears in the settings panel.
- Use ULIDs as database primary keys, sort keys, or distributed identifiers.
Real-world examples
Database primary key design
A backend engineer designs a PostgreSQL schema for a high-write event logging table. UUID v4 primary keys caused index fragmentation because each insert landed at a random B-tree position. They switch to ULID primary keys. Now inserts append to the end of the index, reducing page splits by 80%. They generate test ULIDs with this tool to verify their migration scripts and benchmark insert throughput.
Distributed event ordering
A microservices team needs to merge events from multiple services into a single audit log. They use ULIDs as event IDs. When they query the log ordered by ID, events appear in approximate chronological order without needing a separate timestamp column. The team generates sample ULIDs to test their merge logic and verify that lexicographic sorting matches time ordering.
Debugging a production issue
A developer finds a ULID in a log file: "01H8Y5K1ZQ8J9R0V3M6X2B4C7D". They paste it into the tool's input field and see the decoded timestamp: 2024-09-15T14:23:45.000Z. This tells them exactly when the record was created, helping them correlate the log entry with other events in the system.
Comparison with similar methods
| Method | Complexity | Typical use |
|---|---|---|
| ULID | Low | Sortable unique IDs for database primary keys |
| UUID v4 | Low | Standard unique IDs, RFC 4122 compliant |
| NanoID | Low | Compact URL-safe IDs, not sortable |
| Snowflake ID | Medium | Distributed sortable IDs requiring coordination |
Limitations or considerations
ULIDs generated within the same millisecond are not guaranteed to be in monotonic order. If you generate 100 ULIDs in a single millisecond, their sort order within that millisecond is random. For guaranteed monotonic ordering, use a monotonic ULID factory that increments the random portion. The 80-bit random entropy is lower than UUID v4's 122 bits, but the collision probability per millisecond (1 in 2^80) is still negligible. ULIDs are case-insensitive in Crockford Base32, but some systems treat them as case-sensitive, which can cause comparison bugs if casing is inconsistent.
Frequently asked questions
Can I replace UUID with ULID in my existing system?
In most cases yes. ULIDs are 26 characters vs UUID's 36, so you need to update column types. The sortability property is a bonus for database indexing.
Are ULIDs unique across machines?
Yes. The 80-bit random portion provides 1.2 x 10^24 possibilities per millisecond. The chance of two machines generating the same ULID in the same millisecond is negligible.
How do I decode the timestamp from a ULID?
Paste the ULID into the input field of this tool. The first 10 characters encode the millisecond timestamp, which the tool decodes and displays as an ISO date.
Why does ULID exclude I, L, O, and U?
Crockford Base32 excludes these letters to prevent confusion: I looks like 1, L looks like 1, O looks like 0, and U can accidentally form offensive words in combination.
Is ULID an RFC standard?
No. ULID is an open community specification hosted on GitHub. It is not an IETF RFC like UUID, but it is widely implemented across languages.
Conclusion
ULID is the right choice when you need unique identifiers that also sort by creation time. Use this generator for development, testing, and debugging. For non-sortable compact IDs, try the NanoID Generator. For RFC-compliant identifiers, use the UUID Generator.