ULID generator
What is an Ulid Generator?
A ULID (Universally Unique Lexicographically Sortable Identifier) is a 128-bit identifier like a UUID, but designed to sort by creation time. It is written as 26 characters in Crockford's Base32, for example 01JBCX3M8Q5Z7W2K9R4T6Y0HNA. ULIDs make excellent database primary keys and event IDs where both uniqueness and ordering matter.
How to use it
- Choose how many ULIDs to generate.
- Copy them, one per line.
Structure
- First 10 characters: a 48-bit Unix timestamp in milliseconds, valid until the year 10889.
- Last 16 characters: 80 bits of cryptographically secure randomness.
Because the timestamp comes first and Base32 characters sort in order, sorting ULIDs as plain strings sorts them by creation time.
ULID vs. UUID
- UUIDv4 is fully random. Inserting random keys into a B-tree index scatters writes across the index, which can hurt performance in large tables.
- ULID and UUIDv7 are time-ordered, so new rows are appended near the end of the index.
- ULIDs are shorter as text (26 vs. 36 characters), case-insensitive and avoid ambiguous letters (I, L, O, U).
- UUIDv7 is standardised in RFC 9562 and stores natively in UUID columns, which makes it a strong alternative if your database has a UUID type.
Things to know
- A ULID reveals its creation time; do not use it where that is sensitive.
- Within the same millisecond, monotonic generators increment the random part to keep strict ordering.
Frequently Asked Questions
What is a ULID?
A 128-bit unique identifier written as 26 Base32 characters, with a timestamp first so IDs sort by creation time.
Is a ULID better than a UUID?
For database keys that should be ordered by time, ULIDs and UUIDv7 perform better than random UUIDv4. Choose UUIDv7 if your database has a native UUID type.
Can I get the creation time from a ULID?
Yes. The first 10 characters encode the Unix timestamp in milliseconds.
Can two ULIDs collide?
Practically no. Each millisecond has 80 bits of randomness, so collisions are astronomically unlikely.