UUID Generator

This pane writes version-4 UUIDs. The 4 at the start of the third group is the version, and the 8, 9, a, or b at the start of the fourth group is the variant; the rest is random. The head sets the count and the spelling: lowercase, uppercase, braces, or urn:uuid:. Changing the spelling does not draw new random bits. Generate does.

A version-4 UUID is 128 bits with two fixed fields

The canonical text is 32 hex digits in five groups, 8-4-4-4-12. Four bits in the third group say the version, and two bits in the fourth group say the variant. Version 4 fills the other 122 bits from a random source. Uppercase, braces, and a urn:uuid: prefix change the spelling, not those bits. A hash is a function of some content — see hash digest. A password is a secret drawn from a character set — see password generator. A UUID is an identifier, and it is not either of those.

What the groups, the version, and the variant each mean

Why the text form is five hex groups and not 128 separate flags

  1. The value is 16 bytes. The usual text writes them as hex with hyphens after 8, 12, 16, and 20 digits.
  2. That is 36 characters. Dropping the hyphens leaves 32 hex digits, the same 128 bits if a reader puts the hyphens back.
  3. A reader that requires the hyphenated form will reject the compact string even when the bits match.
  4. Hex a–f is case-insensitive for the value. Uppercase and lowercase are one identifier written two ways.

Why version 4 puts a 4 in the third group and 8, 9, a, or b in the fourth

  1. The version is the high 4 bits of byte 6, which is the first hex digit of the third group. Version 4 writes 4 there.
  2. The RFC 4122 variant is the top two bits of byte 8, set to 10. The first hex digit of the fourth group is then 8, 9, a, or b.
  3. Those six bits are not random. The other 122 bits are.
  4. A string that has a different digit in either of those places is some other version or variant, even if it has the same hyphens.

Why GUID and UUID name one layout and several spellings

  1. GUID is the name used on Windows for the same 128-bit identifier. UUID is the IETF name.
  2. The braced form {8-4-4-4-12} is a Microsoft spelling. The braces are not extra bits.
  3. urn:uuid: is a URN wrapper around the same 36-character body. The prefix is not part of the 128 bits.
  4. A uuid column stores 16 bytes and accepts several spellings. A character column stores whatever letters you wrote.

Why a version-4 value does not sort into the order it was created

  1. Version 1 stores a timestamp and a node. The high bits are time, so the text tends to increase with time, and it can reveal a clock or a MAC address.
  2. Version 4’s high bits are random. Lexicographic order is not creation order.
  3. Version 7, from RFC 9562, puts a Unix millisecond timestamp in the high bits and random bits after that, so new values sort after older ones.
  4. The nil UUID is 128 zero bits. It is a named sentinel, not a value drawn from the random space.

Where an identifier, a digest, and a secret part ways

A row id that must not leak the clock or the machine

Version 4 does not encode when the row was inserted or which host minted it. Version 1 can. A database unique constraint is still what refuses the rare clash; the generator never sees the table.

A string that will be copied into logs and URLs

Anyone who can see the UUID can name that row. It is not a password and not a signature. A digest changes when the content changes. A version-4 UUID stays put if the row is edited, because it was never a function of the row.

Frequently asked questions

What is the difference between a UUID and a GUID?
They are two names for a 128-bit identifier written as hex groups 8-4-4-4-12. UUID is the name in the IETF specs, RFC 4122 and later RFC 9562. GUID is the name used in Windows and COM. The braced uppercase string that Windows often prints is a spelling of those same bits: the braces and the capital letters are not a wider value and not a second identifier. The binary GUID layout stores the first three fields little-endian in memory, but the printed groups are still the same groups. A system that asks for a GUID string and a system that asks for a UUID string are usually asking for this layout, and they may still disagree about braces, case, or a urn:uuid: prefix.
What do the 4 and the 8 in a UUID v4 mean?
They are fixed fields, not lucky random digits. The first hex digit of the third group is the version, four bits taken from the high half of byte 6. Version 4 writes a 4 there. The first hex digit of the fourth group is the variant. For the RFC 4122 variant the top two bits of byte 8 are 10, so that digit is 8, 9, a, or b. Everything else in a version-4 UUID is random, which is 122 bits: 128 minus the 4 version bits minus the 2 variant bits. If either of those digits is something else, the string may still look like 8-4-4-4-12 and still be a different version or a different variant. The hyphens only mark the groups. They do not encode the version.
Can two UUID v4 values collide?
They can, and the chance is the birthday problem on 122 random bits. A collision becomes likely only after on the order of 2^61 values, around two billion billion. A few million identifiers, or even a few billion, sit far below that. “Far below” is not “checked against your table.” Two generators that never talk to each other can still draw the same 122 bits. A unique constraint, or a primary key, is what turns that draw into a refusal. The nil UUID, all zeros, is not part of this random space. It is a reserved sentinel, so it should not be used as a freshly minted id.
What do braces and urn:uuid: change?
They change the wrapper, not the 128 bits. {8-4-4-4-12} is the spelling common in COM and older Windows samples. urn:uuid: followed by the 36-character form is a URN, a namespaced string, from the UUID URN rules. Strip the braces or the prefix and the body is the same identifier, if the body itself is the same hex. A parser that expects a bare UUID will reject the wrapper, and a parser that expects the URN will reject the bare form. Neither wrapper adds entropy. Uppercase is the same kind of change: the hex value is case-insensitive, but a string compare that does not fold case will treat the two writings as different text.
Are UUIDs case-sensitive?
The 128-bit value is not. Hex digits a through f mean the same number in uppercase and lowercase, so a version-4 UUID and the same digits in capitals are one identifier. String equality is a different question. A comparison that does not ignore case, a unique index on a character column, or a signature over the exact characters will treat them as different. A column whose type is uuid stores the 16 bytes and accepts several spellings of the same value. A CHAR(36) or a text column stores the letters you wrote. Braces and a urn:uuid: prefix are also extra characters. They are not a change of case, and they do not compare equal to the bare hex unless the reader strips them first.
How do UUID v1, v4, and v7 differ?
The version nibble says which layout the other bits use. Version 1 puts a 60-bit timestamp, counting 100-nanosecond intervals from 15 October 1582, in the front, then a clock sequence and a node. The node was often a MAC address, so a version-1 value can reveal a machine and a time. Version 4 leaves 122 bits random and only fixes the version and the variant, so it does not encode when or where it was minted. Version 7, specified in RFC 9562, puts a 48-bit Unix timestamp in milliseconds in the high bits and random bits after that. New version-7 values sort after older ones. A version-4 value does not, because its high bits are random. The hyphen positions stay the same across these versions. The digit after the second hyphen is what tells them apart.
Why doesn’t a UUID v4 sort by creation time?
Lexical order follows the characters from the left. In a version-4 UUID those characters are random hex, so a value minted a second later is equally likely to sort before or after an older one. The version digit sits in the middle and is always 4, so it does not order anything. Version 1 and version 7 put time in the high bits, which is why their text tends to increase with the clock. Using a version-4 string as a clustered index, or expecting “the last row” to be the newest, fights that layout. A separate timestamp column, or a version whose high bits are time, is what carries order. The 128-bit random identifier only names the row.
Is a 32-digit hex string, or all zeros, still a UUID?
All zeros, 00000000-0000-0000-0000-000000000000, is the nil UUID. It is a reserved name for “no id,” not a version-4 draw: the version digit is 0, not 4. Thirty-two hex digits with no hyphens can be the same 128 bits as the hyphenated form, if you insert hyphens after 8, 12, 16, and 20 digits and the version and variant digits still sit in those places. A reader that demands the 36-character form will reject the compact string. All f, ffffffff-ffff-ffff-ffff-ffffffffffff, is the max UUID in RFC 9562, another sentinel, not a random version 4. A string that is merely “long and hexadecimal” is not a UUID until the groups, the version, and the variant are the ones the spec names.