Developer ToolsCrypto-random

UUID Generator (Version 4)

Version 4 UUIDs are 122 bits of randomness with a fixed version and variant. These are generated by your browser's cryptographic random number generator, so they never travel across a network.

Generator Options

Values are produced locally using crypto.getRandomValues.

Version 4 UUIDs carry no timestamp and no machine identifier, so they leak nothing about when or where they were created.
FIRST VALUE
Generated
Random bits each
Version / variant
Source of randomness
Share & embed

What the 128 bits actually contain

A version 4 UUID is not 128 random bits. Four bits are fixed to mark it as version 4, and two more encode the RFC 4122 variant, leaving 122 bits of actual randomness. That is why every v4 UUID has a 4 at the start of the third group and one of 8, 9, a or b at the start of the fourth. If you see a UUID without that pattern, it is not version 4.

Collision probability, honestly

With 122 random bits you would need to generate roughly 2.7 × 1018 UUIDs before reaching a one-in-a-billion chance of a single collision. For practical purposes that means never — but only if the randomness is genuinely cryptographic. UUIDs built from Math.random() have far less entropy than they appear to, and have caused real collisions in production systems. This page uses crypto.getRandomValues.

Version 4 is not always the right choice

Because v4 values are random, consecutive inserts land in unrelated places in a B-tree index, which fragments database indexes and hurts write throughput at scale. Version 7 UUIDs, standardised in 2024, put a millisecond timestamp in the high bits so they sort roughly by creation time while staying unique. If you are choosing a primary key for a large table, v7 or a database-native sequence is often the better answer.

Formats you will encounter

The canonical form is 36 characters, lowercase, with four hyphens. Microsoft tooling frequently wraps it in braces. The URN form prefixes urn:uuid: and appears in XML and RDF. Some databases store the bare 32 hex characters. All of these represent the same 128 bits, so converting between them is purely cosmetic.

Frequently Asked Questions

What makes a UUID version 4?
Six of the 128 bits are fixed: four mark the version and two mark the RFC 4122 variant. That is why every v4 UUID has a 4 beginning its third group and an 8, 9, a or b beginning its fourth.
How likely is a UUID collision?
With 122 bits of genuine randomness you would need to generate around 2.7 × 10^18 values before the chance of one collision reaches a billion to one. The risk comes from weak randomness, not from the format.
Should I use a v4 UUID as a database primary key?
Often not. Random values scatter across a B-tree index and fragment it, hurting write performance on large tables. Version 7 UUIDs, which embed a timestamp and sort by creation time, or a native sequence, are usually better.
Are these generated on your server?
No. They are produced in your browser by crypto.getRandomValues, the same generator used for cryptographic keys. Nothing is transmitted, so no one else ever sees the values.