UUID Generator (v4)
Generate one or many random version-4 UUIDs in your browser with the cryptographic random source — nothing sent to a server.
1,050 views
What Makes a v4 UUID Unique
A UUID (Universally Unique Identifier) is a 128-bit number, conventionally written as 36 characters split 8-4-4-4-12 in hexadecimal, like f47ac10b-58cc-4372-a567-0e02b2c3d479. Of those 128 bits, version 4 — the variant this generator produces — fills 122 of them with output from a cryptographically secure random number generator. The remaining 6 bits are not random at all: they are fixed markers that identify the UUID as version 4 and mark its "variant," which is why the character right after the second dash is always 4, and the first character of the next group is always 8, 9, a, or b.
122 random bits is an enormous space: 2^122 possible values, roughly 5.3×10³⁶. To make that concrete, if every device on Earth generated a billion UUIDs per second continuously, it would still take on the order of tens of billions of years of combined generation before the odds of a single accidental duplicate reached even 50%. That is why distributed systems — services running on hundreds of independent servers with no coordination between them — can each mint their own UUIDs locally and trust, without checking a central registry, that no two will ever collide. This is the entire point of the format: unique identification without a database lookup.
Generation here happens entirely inside your browser using the Web Crypto API's crypto.randomUUID() function — the same cryptographic random source browsers use for security-sensitive operations. Nothing is sent to a server, no seed is logged, and each UUID you generate is independent of every other.
What to Know Before Using UUIDs
v4 is not the only version. v1 and v6 embed a timestamp and the generating machine's network address, which makes them sortable but also leaks information about when and where they were created. v5 hashes a name you supply, producing the same UUID every time for the same input — useful when you need a deterministic identifier rather than a random one. v7, a newer standard, combines a timestamp prefix with random bits, giving you both uniqueness and natural chronological ordering. v4 remains the right default whenever you simply need a random, non-guessable, collision-free identifier and do not need it to encode a time or a name.
One practical caveat: because v4 values are fully random, using them as a database primary key can hurt insert performance on B-tree-indexed tables, since new rows land in unpredictable positions across the index rather than appending neatly at one end. If insert throughput matters at scale, a time-ordered alternative such as UUIDv7 or ULID keeps the same 128-bit uniqueness guarantee while staying index-friendly.
Frequently Asked Questions
Can two generated UUIDs collide?
Theoretically yes, practically never: with 2^122 possibilities, generating a billion UUIDs per second for 85 years gives roughly 50% odds of a single collision. Systems worldwide rely on this.
Should I use UUIDs as database primary keys?
They shine for distributed generation and non-guessable IDs, but random v4s fragment B-tree indexes. If insert performance matters, look at UUIDv7 (time-ordered) or ULID — same size, index-friendly.
Is v4 the only version?
No — v1/v6 embed a timestamp and MAC address, v5 hashes a name and always produces the same result, v7 is a newer format combining a timestamp with randomness. v4 remains the default choice when you just need a random unique ID.
What are the fixed bits in a v4 UUID for?
Of the 128 bits, only 122 are random. The other 6 are reserved to mark the format itself — one nibble is fixed to signal "version 4," another is constrained to a small set of values (8, 9, a, or b) to mark the "variant." That is why every v4 UUID has a 4 right after the second dash, no matter how many you generate.
Can I use a UUID as a security token, like a password reset link?
A v4 UUID is generated from a cryptographically secure random source, so guessing one is not practical — but it was designed for uniqueness, not secrecy. For anything security-sensitive, pair it with proper expiration, single-use enforcement, and server-side validation rather than relying on the UUID alone.
Similar Tools
Report a Problem
UUID Generator (v4)
Comments
No comments yet — be the first to write one!