UUID Generator (v4)

Generate cryptographically random UUIDs. Useful as primary keys, request IDs, file names.

Standard
UPPERCASE
With {braces}
No hyphens

What is a UUID?

A UUID - Universally Unique Identifier, also called a GUID - is a 128-bit value used to identify something uniquely without needing a central authority to hand out numbers. Any system can generate one independently and be confident it will never collide with any other.

xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx

Example: 550e8400-e29b-41d4-a716-446655440000

The format is 32 hexadecimal digits in five hyphen-separated groups. The M position indicates the version, and the N position encodes the variant.

Key takeaways

  • A UUID is 128 bits, written as 36 characters including four hyphens.
  • Version 4 UUIDs are random - 122 bits of randomness after version and variant bits.
  • Collision probability is negligible: you could generate billions with no realistic risk.
  • UUIDs are identifiers, not secrets - do not use them as security tokens.
  • Random UUIDs make poor database primary keys because they fragment indexes.

UUID versions

VersionBased onSortable?Common use
v1Timestamp + MAC addressRoughlyLegacy; leaks the machine address
v3MD5 of a namespace + nameNoDeterministic IDs from known names
v4Random dataNoThe general-purpose default
v5SHA-1 of a namespace + nameNoDeterministic IDs, preferred over v3
v7Unix timestamp + randomYesModern choice for database keys

This generator produces v4 UUIDs, which is the right default for most purposes. Version 7 is worth knowing about if you are choosing database primary keys.

How unique is "unique"?

A v4 UUID has 122 random bits, giving about 5.3 × 10³⁶ possible values. The chance of a collision is governed by the birthday problem, but the numbers involved are so large that it stops being a practical concern.

UUIDs generatedProbability of any collision
1 millionAbout 1 in 10²⁵
1 billionAbout 1 in 10¹⁹
103 trillionAbout 1 in a billion
2.7 × 10¹⁸About 50%

To reach a 50% chance of a single collision you would need to generate roughly 2.7 quintillion UUIDs. At a billion per second that takes about 85 years.

The real risk is not mathematics, it is implementation. Collisions in practice come from weak random number sources - a virtual machine cloned with an identical random seed, or an embedded device with no entropy at startup. This generator uses the browser's cryptographically secure source, which avoids that class of problem.

Where UUIDs are used

  • Database primary keys, particularly in distributed systems where rows are created in several places at once.
  • Distributed system correlation IDs, tracing a request across many services.
  • Idempotency keys, so a retried API call is not processed twice.
  • File and object names where collisions must be impossible.
  • Session and transaction identifiers in logging.
  • Message IDs in queues and event streams.

UUIDs as database keys: the trade-offs

Auto-increment integerUUID v4UUID v7
Generated byThe databaseAnywhereAnywhere
Storage size4-8 bytes16 bytes16 bytes
Index localityExcellent - sequentialPoor - random insertsGood - time-ordered
Reveals record count?YesNoPartially (timing)
Safe to expose publicly?Not idealYesMostly
Sortable by creationYesNoYes
Why random UUIDs hurt database performance. B-tree indexes work best when new keys are appended at the end. Random UUIDs insert at arbitrary positions, causing page splits and fragmentation throughout the index, and destroying cache locality. On large tables this is measurable. UUID v7, which prefixes a timestamp, restores sequential ordering while keeping global uniqueness.

UUIDs are not secrets

Do not use a UUID as a security token. A v4 UUID is unguessable in practice, but it is designed for uniqueness rather than secrecy, and other versions leak information - a v1 UUID contains a timestamp and the generating machine's MAC address. Password reset links, API keys and session tokens should use a purpose-built cryptographically secure random string.

If you need an unguessable token, the random string generator is the appropriate tool.

Everything runs in your browser. This tool is implemented entirely in client-side JavaScript. Nothing you enter is transmitted to a server, logged or stored, which matters a great deal for anything security-related. You can verify this yourself by opening your browser's network tab and watching it stay empty while you work.

Frequently Asked Questions

What is a UUID?

A Universally Unique Identifier - a 128-bit value written as 32 hexadecimal digits in five hyphen-separated groups. It lets any system generate an identifier independently, without a central authority, and be confident it will not collide with any other.

What is the difference between a UUID and a GUID?

Nothing meaningful. GUID is Microsoft's name for the same 128-bit identifier standard. The terms are used interchangeably, though UUID is the name used in the formal specification.

What is UUID v4?

The random variant. After the version and variant bits are fixed, 122 bits are filled with random data, giving about 5.3 × 10³⁶ possible values. It is the right default for most purposes because it requires no coordination and leaks no information.

Can two UUIDs ever be the same?

In theory yes, in practice no. You would need to generate roughly 2.7 quintillion v4 UUIDs before reaching a 50 percent chance of a single collision. Real-world collisions come from weak random sources, such as cloned virtual machines sharing a seed, not from the mathematics.

Are these UUIDs cryptographically secure?

The randomness is - this generator uses the browser's cryptographically secure random source. That does not make a UUID suitable as a secret, however. Use a purpose-built random token for security purposes rather than a UUID.

Should I use UUIDs as database primary keys?

It depends. They are excellent in distributed systems where several nodes create records simultaneously, and they avoid exposing how many records you have. But random v4 UUIDs fragment B-tree indexes badly on large tables. UUID v7, which prefixes a timestamp, avoids that problem.

Why do random UUIDs slow down databases?

Because B-tree indexes perform best when new keys append at the end. Random UUIDs insert at arbitrary positions, causing page splits throughout the index and destroying cache locality. Sequential integers or time-ordered UUID v7 avoid this.

Can I use a UUID as a password reset token?

Better not to. UUIDs are designed for uniqueness rather than secrecy, and some versions leak information - a v1 UUID embeds a timestamp and the generating machine's MAC address. Use a cryptographically secure random string generated specifically as a token.

Are my generated UUIDs stored anywhere?

No. Generation happens entirely in your browser and nothing is transmitted or recorded. Refreshing the page discards everything.

Related Calculators