UUID Generator (Version 4 and Version 7)
Choose version 4 (random) or version 7 (time-ordered) and how many to make. UUIDs are created in your browser with its cryptographic random source and are never sent or saved.
Last reviewed
Press Generate to make UUIDs. Each press makes new ones in your browser, and nothing is saved or sent.
What a UUID is
A UUID (universally unique identifier) is a 128-bit number written as 32 hexadecimal digits in five groups, like 919108f7-52d1-4320-9bac-f847db4148a8. The groups are 8, 4, 4, 4 and 12 digits long. They are used as database keys, file names, request IDs and anywhere you need an identifier that two systems can create independently without clashing.
The standard is RFC 9562. This tool makes the two versions that people choose for new work, in your browser, using its cryptographic random source. Nothing is sent anywhere, and the UUIDs are never put in the page address.
Version 4: random
A version 4 UUID is almost all random. Of the 128 bits, 6 are fixed: 4 hold the version number, 0100, and 2 hold the variant, 10. The other 122 bits are random. The version digit is the first digit of the third group, so every version 4 UUID has a 4 there, and the first digit of the fourth group is 8, 9, a or b.
The example in the RFC (Appendix A.3) is built from these fields: random_a 0x919108f752d1, version 4, random_b 0x320, variant 10 and random_c, giving 919108f7-52d1-4320-9bac-f847db4148a8.
Version 7: time-ordered
A version 7 UUID starts with a 48-bit timestamp in milliseconds since the Unix epoch, followed by the version (0111), 12 random bits, the variant (10) and 62 random bits. Because the timestamp comes first, version 7 UUIDs sort by creation time, which is kind to database indexes. The price is that the time is visible inside the UUID.
The RFC’s example (Appendix A.6) has unix_ts_ms 0x017F22E279B0, version 7, rand_a 0xCC3, variant 10 and rand_b 0x8C4DC0C0C07398F, which gives 017F22E2-79B0-7CC3-98C4-DC0C0C07398F. The timestamp 0x017F22E279B0 is 1,645,557,742,000 milliseconds, which is 22 February 2022 at 19:22:22 UTC. Paste a version 7 UUID into the “Check a UUID” box and the page reads that time back.
UUIDs made in the same millisecond share a timestamp. Their order among themselves is random.
How unlikely is a clash?
With 122 random bits there are 2^122 possible version 4 UUIDs, which is about 5.3 × 10^36. The chance of any two among n of them matching is about n(n − 1) ÷ (2 × 2^122) (the birthday approximation):
| UUIDs made | Chance of any clash (approximately) |
|---|---|
| 1 million | 9.4 × 10^-26 |
| 1 billion | 9.4 × 10^-20 |
| 1 trillion | 9.4 × 10^-14 |
| 1 quadrillion | 9.4 × 10^-8 |
The chance of a clash reaches one half only after about 2.7 × 10^18 UUIDs. That holds if the random source is good. This tool uses the browser’s cryptographic generator, and a poor source would break the assumption.
Choosing a version
- Version 4 when you want an identifier that reveals nothing.
- Version 7 when you want identifiers that sort by time, for example as database keys, and you accept that they show roughly when they were made.
- Neither is a secret. A UUID is an identifier, not a password or a token to protect access, so do not rely on it staying unguessable for security.
Formats
The settings change only how the same bits are written: upper-case letters, no hyphens (32 digits in a row), or braces around the whole value. They are all the same UUID.
Common mistakes
- Treating a UUID as a secret. Use a proper random token for that.
- Comparing UUIDs as case-sensitive text. Upper and lower case are the same value.
- Using version 4 as a sortable key. Its order is random, which scatters inserts in an index.
- Expecting version 7 to be strictly increasing. Two made in the same millisecond have no order.
For other generators, see the password generator, the hash generator and the JWT decoder.
How it is made
Random bytes come from the browser’s cryptographic generator. For version 4, the version and variant bits are set on 16 random bytes. For version 7, the first 6 bytes hold the current time in milliseconds, 10 random bytes follow, and the version and variant bits are set. The bytes are then written as hexadecimal in the 8-4-4-4-12 pattern.
Frequently asked questions
What is the difference between UUID v4 and v7?
Version 4 is random apart from 6 fixed bits, so it has 122 random bits and no order. Version 7 starts with a 48-bit millisecond Unix timestamp, so values sort by creation time, and the rest is random.
Can two UUIDs ever be the same?
In theory, but with 122 random bits it is astronomically unlikely. After a billion version 4 UUIDs the chance of any clash is about 9.4 × 10^-20, and it only reaches one half after about 2.7 × 10^18, given a good random source.
Is a UUID the same as a GUID?
In practice yes. GUID is the name Microsoft uses for the same 128-bit identifier, often written in upper case and inside braces. The tool offers both of those options.
Is it safe to use a UUID as a secret or token?
No. A UUID is an identifier. A version 7 UUID even contains its creation time. Use a proper random token from a cryptographic generator for anything that protects access.
Are the UUIDs generated here sent anywhere?
No. They are made in your browser with its cryptographic random source when you press Generate. Only the settings, never the UUIDs, are written to the page address if you copy the link.
How do I read the time in a version 7 UUID?
The first 12 hex digits are the Unix time in milliseconds. The RFC example 017F22E2-79B0-7CC3-98C4-DC0C0C07398F starts with 0x017F22E279B0, which is 22 February 2022 at 19:22:22 UTC. Paste a UUID into the check box to see it.
Related calculators
- Password GeneratorChoose a length and the kinds of character to use, then press Generate.
- Hash GeneratorType or paste text and see its MD5, SHA-1, SHA-256, SHA-384 and SHA-512 hashes at once, as hex or base64.
- JWT DecoderPaste a JSON Web Token.
- Cron Expression GeneratorFill in the minute, hour, day of month, month and day of week, or start from a common schedule.
- Color Contrast CheckerEnter a text colour and a background colour as hex codes.
- PX to REM ConverterEnter a size in pixels or rem and your root font size.