Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path
UUID & ULID Generator
A UUID and ULID generator. Produce cryptographically-random version-4 UUIDs or sortable ULIDs, one at a time or in bulk, with one-click copy. Explains when to reach for a random UUID versus a time-sortable ULID, and shows the structure of each. Uses the browser’s secure crypto — nothing is generated on or sent to a server.
122 random bits — unordered, reveals nothing. The default distributed ID.
fbc525b0-41e6-48b1-8825-c8a50905e9e3⧉85453a16-bb03-49f8-add7-26f10c8a9678⧉de4871eb-d414-4c67-b588-91859abfb1e6⧉b90a6133-d785-4400-a1bf-5698a17f7389⧉6b83c834-3dcc-4098-b3ae-770d2c3e1bac⧉
Sometimes you need an ID that any machine can mint without asking anyone. UUIDs and ULIDs are 128-bit identifiers, random enough that independent generators never realistically collide, so no central sequence or coordinator is needed. A browser, an offline device and three servers can all create rows that will never clash.
What it computes
The generator produces two formats, from 1 to 100 at a time, using the browser’s cryptographically secure random source:
UUID v4 xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
32 hex digits in groups of 8-4-4-4-12
4 = version; y is 8, 9, a or b (RFC 4122 variant)
122 random bits
ULID TTTTTTTTTTRRRRRRRRRRRRRRRR
10 characters: 48-bit millisecond Unix timestamp
16 characters: 80 random bits
26 characters of Crockford base32
- The Crockford alphabet is
0123456789ABCDEFGHJKMNPQRSTVWXYZ. It leaves out I, L, O and U so IDs are hard to misread. - Each character carries 5 bits. The timestamp is written most significant first, so later times produce lexicographically larger strings.
- Each random ULID character uses 5 random bits, so all 80 bits are random and uniform.
A worked example
Take a ULID created at Unix time 1700000000000 ms (November 14, 2023, 22:13:20 UTC). Dividing by 32 ten times and mapping each remainder to the alphabet gives the timestamp part 01HF7YAT00. One millisecond later it is 01HF7YAT01, which sorts after it. The remaining 16 characters are random, so a full ID looks like 01HF7YAT00 followed by sixteen random characters.
| Property | UUID v4 | ULID |
|---|---|---|
| Length | 36 characters with hyphens | 26 characters |
| Random bits | 122 | 80, plus 48 of time |
| Sorts by creation time | No | Yes, to the millisecond |
| Reveals creation time | No | Yes |
| Case | Lowercase hex | Uppercase base32 |
A v4 UUID such as 123e4567-e89b-42d3-a456-426614174000 shows the fixed markers: the 15th character is 4 for the version and the 20th is a, one of the four variant digits. Everything else is random.
Assumptions and limits
- No monotonic counter. Two ULIDs in the same millisecond are unique but their order is random. Libraries with a monotonic mode increment the random part to guarantee order.
- Not UUIDv7. A ULID has a similar layout but a different encoding and is not a valid UUID string.
- Not secrets. Identifiers are unique, not confidential.
- No namespace or name-based IDs. Versions 3 and 5, derived from a name, and version 1 are not generated.
- The timestamp is your clock. A wrong device clock produces wrong ULID times.
How to use the result
- Public identifiers: use v4 UUIDs when the ID should say nothing about when or in what order things were created.
- Primary keys: prefer a time-ordered ID, a ULID or UUIDv7, to keep inserts local in the index; store UUIDs in a native 16-byte column rather than as text.
- Do not rely on order across machines. Clock skew means ordering is approximate; use a database sequence if you need strict order.
- Pick one format per system. Mixing UUIDs and ULIDs in one column or API makes validation and sorting harder, and converting between them later is tedious.
- Generate at the edge. Client-generated IDs let you create records offline and make retries idempotent.
When to use it, and when not
Use it when you need a handful of IDs by hand: seed rows and test fixtures, an idempotency key for a request you are replaying with curl, IDs for a one-off migration script, or a sample to check that a validator accepts the format. A batch of 100 copied in one click covers most of those.
Production code should call a library or the platform instead, such as crypto.randomUUID() in browsers and Node or the database’s own UUID function. Use a library too when you need what this page does not make: monotonic ULIDs, UUIDv7, or name-based versions 3 and 5.
Trade-offs and limits
“Never collides” is a probability, set by the number of random bits. The birthday bound gives the chance of any collision among n IDs as roughly n² / 2^(bits + 1):
| Scenario | Random bits | Chance of any collision |
|---|---|---|
| 1 billion UUID v4s | 122 | 9.4 × 10⁻²⁰ |
| 1 billion UUID v4s a second for a year | 122 | 9.4 × 10⁻⁵, about 1 in 10,700 |
| 1,000 ULIDs in the same millisecond | 80 | 4.1 × 10⁻¹⁹ |
| 1 million ULIDs in the same millisecond | 80 | 4.1 × 10⁻¹³ |
A ULID only competes with IDs from its own millisecond, so its 80 bits go further than they look. The maths also assumes a good random source. This page uses Web Crypto and would fall back to Math.random only in a browser without it; no current browser lacks it. Hand-rolled generators seeded from the time or a weak random function are where real collisions come from.
Order matters as much as uniqueness once the ID is a primary key. A B-tree index keeps keys sorted, so each random v4 key lands on a random leaf page, and a large table must keep the whole index in memory to insert quickly. A time-ordered key lands on the most recent pages, which stay hot. UUIDv7, standardised in RFC 9562, takes the ULID’s approach inside the UUID format: the same 48-bit millisecond timestamp first, then the version and variant markers, which leave 74 random bits to the ULID’s 80. It prints as an ordinary 36-character UUID and fits an existing UUID column, which is usually the deciding factor.
The same 13th hex digit identifies any UUID you meet in the wild: 4 is random, 7 is time-ordered, 3 and 5 are hashes of a name, and 1 is the old time-based form. Treat a public version-1 ID with care: it carries its creation time, and often the generating machine’s network address in its last 12 hex digits.
Common mistakes
- Storing UUIDs as 36-character text. A native UUID or 16-byte binary column is 2.25 times smaller. Over 100 million rows that is 1.6 GB of key bytes instead of 3.6 GB, before every index that repeats the key.
- Sorting v4 UUIDs to find the newest row. They are random, so their order means nothing. Sort by a timestamp column, or use a time-ordered ID.
- Comparing IDs case-sensitively. Hex digits and Crockford base32 are both case-insensitive, so
01HF7YAT00…and01hf7yat00…are the same ID. Normalise before comparing, or a uniqueness check lets duplicates in. - Trusting ULID order within a millisecond. This tool’s same-millisecond IDs sort by their random part. If order matters, use a monotonic generator or a sequence.
- Exposing ULIDs where timing is private. Anyone can read the creation time from the first 10 characters, which can reveal when an account was opened or how fast orders arrive.
Check yourself
Is 123e4567-e89b-12d3-a456-426614174000 a version-4 UUID?
No. The version is the 13th hex digit, the first digit of the third group, and here it is 1: a version-1, time-based UUID. Its variant digit, a, is valid. The same string with 42d3 in the third group is the v4 example above.
Two ULIDs begin 01HF7YAT00 and 01HF7YAT10. How far apart were they created? And how long a window do IDs sharing their first six characters span?
The last time character counts milliseconds and the one before it counts groups of 32, so 10 minus 00 is 32 ms. Six shared characters leave four free, 32⁴ = 1,048,576 ms, about 17.5 minutes.
What is the largest valid ULID timestamp, and why can the first character never exceed 7?
Ten base32 characters hold 50 bits, but the timestamp is only 48, so the first character carries just 3 bits: 0 to 7. The maximum, 7ZZZZZZZZZ, is 2⁴⁸ − 1 ms, which falls in the year 10889.
A fleet makes 1 billion v4 UUIDs every second for a year. Should it worry about a collision?
That is n = 3.16 × 10¹⁶ IDs. n² / 2¹²³ ≈ 9.4 × 10⁻⁵, about 1 in 10,700 for the whole year. Not zero, but a database unique constraint, which catches it if it ever happens, is cheaper than any redesign.
How it works
- v4 UUIDs from the browser’s crypto: 122 random bits, 8-4-4-4-12 hex.
- ULIDs: 48-bit ms timestamp + 80 random bits, 26 Crockford base32 characters.
- Generates 1 to 100 at a time with one-click copy, one or all.
- Explains UUID (unordered) vs ULID (time-sortable) trade-offs.
Frequently asked questions
What is a version-4 UUID?
A UUID, Universally Unique Identifier, is a 128-bit value written as 32 hexadecimal digits in an 8-4-4-4-12 pattern. Version 4 fills almost every bit with random data: 122 random bits, with 6 fixed to mark the version and variant. Two independently generated v4 UUIDs colliding is astronomically unlikely, so they can be created anywhere with no central coordinator, which makes them the default choice for distributed identifiers. The 13th hex digit is always 4.
What is a ULID and how is it different?
A ULID, Universally Unique Lexicographically Sortable Identifier, is also 128 bits, but split into a 48-bit millisecond timestamp followed by 80 random bits, written as 26 characters of Crockford base32. Because the high bits are time, ULIDs created later sort after earlier ones as ordinary strings. That makes them friendlier as database keys: inserts stay roughly in order instead of scattering across the index the way random UUIDs do.
When should I use a UUID vs a ULID?
Use a random v4 UUID when the ID should reveal nothing and ordering does not matter: public identifiers, external references, or any system that expects a standard UUID column. Prefer a ULID, or a UUIDv7, which has the same time-ordered idea, when the ID is a primary key and insert locality matters. Time-sortable keys reduce index fragmentation and give a free creation ordering. The trade-off is that a ULID reveals when it was created.
Can two UUIDs or ULIDs collide?
In theory yes, in practice almost never. With 122 random bits, you would need to generate about 2.7 quintillion v4 UUIDs, roughly 2.7 × 10¹⁸, before the chance of any collision reaches 50%. A ULID has 80 random bits per millisecond, so a collision needs two IDs generated in the same millisecond with the same random part. This tool does not enforce monotonic ordering, so two ULIDs created in one millisecond are unique but not guaranteed to sort in creation order.
Are these safe to use as secrets or tokens?
No. A UUID or ULID is an identifier, not a credential. It is built to be unique rather than unguessable in a security sense, and a ULID exposes its creation timestamp. For session tokens, API keys or password-reset links, generate a dedicated high-entropy secret, such as 256 random bits from a cryptographically secure generator, and store it as carefully as a password. This tool does use the browser’s secure random source, but the format is the wrong shape for a secret.