Skip to main content
UtilitiesFree · no sign-up

UUID Generator

Version 4 UUIDs from the browser cryptographic random source, in bulk if you need them.

Updated

One to 500 at a time. They are generated in this browser and never sent anywhere.

Your UUIDs

Generating in your browser. If nothing appears, your browser has blocked its cryptographic random generator.

Every one of these is a version 4 UUID: 122 random bits, with four bits spent on the version and two on the variant. The chance that this batch of 0 contains a repeat is about 0, which is very small rather than zero. Use them as identifiers, never as a password, session token, or anything else that has to stay secret.

In short

How likely is it that two version 4 UUIDs collide?

A version 4 UUID carries 122 random bits, so there are about 5.3 times 10^36 of them. Draw 103 trillion and the chance any two match is roughly 1 in a billion. You would need about 2.7 times 10^18 before a repeat is more likely than not. That is very small rather than zero, and no page should call it impossible.

Those odds hold only if the bits really are random, which means a cryptographic generator rather than a seeded pseudo-random one.

How to use the UUID generator

Set the count, pick a format, and the identifiers appear straight away. Pressing "Generate new" replaces the whole batch, and changing the format rewrites what is already on screen rather than drawing fresh values, so an identifier you have already pasted somewhere does not quietly change underneath you.

Everything happens in the page in front of you. The values come from your browser cryptographic random generator, nothing is sent to a server, nothing is logged, and no identifier is ever written into the URL. Close the tab and the batch is gone.

122

Random bits per UUID

128 total, minus version and variant

5.3 x 10^36

Distinct version 4 UUIDs

that is 2 to the power 122

500

Most this tool makes at once

copied as one line each

The four formats carry exactly the same bits. Hexadecimal is case insensitive, so uppercase changes nothing about the value, and the hyphens are punctuation rather than data. Choose whichever the receiving system prints, because matching its output makes a mismatch obvious at a glance.

The four ways of writing the same value
Lowercase, hyphenated
the canonical form in RFC 9562
Uppercase
common in .NET and older Windows tooling
Braced
the Microsoft GUID registry style
No hyphens
32 characters, used in URLs and some APIs

All four are the same 128 bits. Only the punctuation and the letter case differ.

A UUID is an identifier, not a secret

If you need something an attacker must not guess, generate a password or a key with a tool built for the job instead.

Open the password generator

Version 4 is random and version 7 is time ordered. Both are defined in RFC 9562, and both use the same 128-bit layout. A v7 identifier puts a millisecond timestamp in its high bits, so a list of them sorts into creation order without a separate column.

That difference matters most in a database. Random keys land in random pages of a B-tree index, so a busy table keeps rewriting pages all over the disk. Time-ordered keys append near the end, which is cheaper to write and friendlier to the cache.

Do

  • Store the 128 bits as a native uuid column when your database has one.
  • Keep the canonical lowercase form as the value you compare on.
  • Use version 7 when the identifier is also the primary key.
  • Generate a fresh identifier per row rather than reusing one across tables.
  • Say "very unlikely to repeat" in documentation rather than "unique".

Don't

  • Put a UUID in a password reset link and call it security.
  • Store the hyphenated text in a 36-character varchar out of habit.
  • Compare two identifiers with a case-sensitive string equality check.
  • Assume a value that looks like a UUID came from a random source.
  • Shorten one to its first eight digits to save room in a table.

The chance that a batch of version 4 UUIDs contains at least one repeat, by how many you draw, using the birthday bound over the 2 to the power 122 random values.

UUIDs drawnChance of at least one repeatAs a fraction
1 million9.4 x 10^-261 in 1.1 x 10^25
1 billion9.4 x 10^-201 in 1.1 x 10^19
1 trillion9.4 x 10^-141 in 1.1 x 10^13
103 trillion1.0 x 10^-91 in 1 billion
1 quadrillion9.4 x 10^-81 in 10.6 million
3.3 x 10^171.0 x 10^-21 in 100
2.7 x 10^185.0 x 10^-11 in 2
Computed as 1 minus e to the power of minus n squared over 2N, with N = 2^122 = 5,316,911,983,139,663,491,615,228,241,121,378,304. That approximation runs slightly high for small n, which is the honest direction to be wrong in. It assumes every UUID comes from a genuinely random source; a weak generator invalidates the whole table.

Should a database key be version 4 or version 7?

Version 7 in almost every case where the identifier is also the primary key. RFC 9562 added it in May 2024 precisely because random keys behave badly in an index, and the fix is to move the entropy out of the high bits and put a timestamp there instead.

A version 7 value begins with 48 bits of Unix milliseconds, then the version nibble, then 74 random bits. Two rows created in the same millisecond still differ, and rows created in order sort in order, which is what a B-tree wants.

  • Primary key on a table that grows: version 7.
  • Identifier shown to a user or sent to a third party: version 4 leaks nothing about timing.
  • Correlation id in a log or trace: version 4 is fine and simpler.
  • Anything that must be unguessable: neither, use a secret generator.

Version 4 is still the right answer whenever the creation time is itself sensitive. A v7 identifier tells anyone who receives it roughly when the record was made, down to the millisecond, and that is information you may not want to hand out with an order number.

Why a UUID is not a security token

Unguessable and unlikely to repeat are different properties. A version 4 UUID from a cryptographic source has 122 bits of entropy, which sounds like plenty, and in isolation it is. The problem is everything else the format encourages.

Identifiers get printed in URLs, server logs, analytics payloads, error reports and support tickets. A secret that has been through all of those is no longer a secret, and no amount of entropy fixes a value that was designed to be shared.

There is a second trap. Not every UUID-shaped string came from a cryptographic source: plenty of older libraries built them from the clock, the process id and a weak pseudo-random function. A value that looks like a v4 UUID tells you nothing about how it was made.

The formula, worked line by line

A UUID is 128 bits, written as 32 hexadecimal digits in five hyphenated groups. In version 4 all of those bits start out random and then six of them are overwritten: four for the version and two for the variant. What survives is 122 bits of genuine unpredictability.

Collision odds are not one divided by the number of values. They follow the birthday problem, because a repeat can happen between any pair in the batch and the number of pairs grows with the square of the batch size. That is why the answer arrives far sooner than intuition suggests.

total bits = 128
version nibble = 4 bits, forced to 0100
variant bits = 2 bits, forced to 10
random bits = 128 - 4 - 2 = 122
distinct values N = 2^122 = 5,316,911,983,139,663,491,615,228,241,121,378,304
P(at least one repeat in n draws) = 1 - e^(-n^2 / 2N)
n for a given probability p = sqrt(2N x ln(1 / (1 - p)))
Where the version and variant bits sit in a UUIDA version 4 UUID is 128 bits written as 32 hexadecimal digits in five groups. The 13th digit is always 4, the version, and the 17th is 8, 9, a or b, because its top two bits are forced to 10 for the variant. That leaves 122 bits random. In this example byte 6 is drawn as 2a and stored as 4a, and byte 8 is drawn as 6c and stored as ac.128 BITS = 4 VERSION + 2 VARIANT + 122 RANDOM3f812a6c-d5e0-4a93-ac1f-b4770e51c9a8version: always 4variant: 8, 9, a or bTHE TWO BYTES THAT GET REWRITTENbyte 6 drawn 0x2astored 0x4abyte 8 drawn 0x6cstored 0xacevery other bit is stored exactly as drawnTHE BIT BUDGETtotal bits128version + variant6random122 bits
Six of the 128 bits are spoken for: four for the version, two for the variant.
One billion UUIDs, worked through
Batch size n
1,000,000,000
n squared
1 x 10^18
2N
1.06 x 10^37
n squared over 2N
9.4 x 10^-20
Chance of a repeat
9.4 x 10^-20

Run the same arithmetic backwards and you get the number that matters more: about 2.7 x 10^18 draws before a repeat is more likely than not. A billion is a very long way below that, which is why v4 is safe in practice while still not being guaranteed.

Two of the digits give the format away. Take the canonical form, count to the first digit of the third group, and a version 4 identifier always shows a 4 there. The first digit of the fourth group is always 8, 9, a or b, because its top two bits were forced to 10.

This tool sets those bits by hand only when it has to. Where the browser provides its own UUID function it is used directly, because a runtime implementation is better tested than anything a web page can write. The fallback takes 16 random bytes and rewrites the same two positions.

The entropy figure only describes the process. If a library seeds a fast pseudo-random function with the current time, the output still has the shape of a v4 UUID and still passes a format check, while the real number of possible values may be a few million rather than 5.3 x 10^36.

Questions people ask

Sources

Where the constants and formulas on this page come from. Each line names the figure it backs.

  1. Version 4 is random apart from the 4 version bits and 2 variant bits, and version 7 places a 48-bit big-endian Unix millisecond timestamp in the high bits so keys sort by time.

    RFC 9562: Universally Unique IDentifiers (UUIDs)IETF, 2024, obsoletes RFC 4122