UUIDs that sort by creation time
Here’s the problem with UUID v4: it’s random. Great for uniqueness, terrible for database performance. Random primary keys cause B-tree index fragmentation. Your inserts scatter across the index instead of appending to the end. Range queries by creation time require a separate timestamp column and index.
ULIDs fix this. They’re 26 characters in Crockford Base32, and they sort lexicographically by creation time. The first 10 characters encode a millisecond-precision timestamp. The last 16 are cryptographically random. Records created later always have higher ULID values, which means sequential inserts, happy B-trees, and free chronological ordering.
The structure
01ARZ3NDEK TSVE4RRFFQ69G5FAV
|-- timestamp --| |-- randomness --|
(10 chars) (16 chars)
48-bit ms 80-bit random
The timestamp is milliseconds since Unix epoch. The random portion uses crypto.getRandomValues, the browser’s cryptographically secure RNG. Even within the same millisecond, the 80-bit random component makes collisions practically impossible (2^80 possible values per ms).
Why ULIDs over UUIDs
Database performance. Sequential inserts. No index fragmentation. Faster writes, faster range queries.
Built-in timestamps. Extract the creation time from any ULID without a database lookup. The first 10 characters encode millisecond precision.
Shorter. 26 characters vs UUID’s 36. More compact in URLs, API responses, and storage.
Human-friendly encoding. Crockford Base32 excludes I, L, O, and U, characters that get confused with 1, 1, 0, and V. Fewer transcription errors.
Chronological sorting. ORDER BY id gives you creation order for free.
Generate in bulk
Create 1 to 100 ULIDs at once. Toggle between uppercase and lowercase output. Click any ULID to copy it, or use “Copy All” for the whole batch.
For shorter, non-time-ordered IDs, check out the Nano ID Generator.
FAQ
How are ULIDs different from UUIDs?
Time-ordered (sorts chronologically), shorter (26 vs 36 chars), encoded in Crockford Base32 (not hex), and embeds a millisecond timestamp. UUID v4 is purely random.
Multiple ULIDs in the same millisecond?
The 80-bit random component handles it. The probability of collision within a millisecond is astronomically low.
Can I extract the timestamp?
Yes, the first 10 characters decode to milliseconds since Unix epoch. Any ULID library can do it, or you can manually convert the Crockford Base32.
What’s Crockford Base32?
32 characters: 0-9 and A-Z, minus I, L, O, U. Case-insensitive, human-friendly, avoids visually ambiguous characters.
Client-side?
All generation happens in your browser using the Web Crypto API.