UUID vs GUID Explained: Versions 1, 4, and 7 (and Which One to Use)

UUID vs GUID explained: what a UUID is, why GUID is the same thing, and when to use version 1, 4 or 7. Plus a free UUID v4 generator.

By Vincent RuanPublished June 25, 2026Last updated October 4, 20268 min read

Illustration for this article: UUID vs GUID explained: what a UUID is, why GUID is the same thing, and when to use version 1, 4 or 7. Plus a free UUID v4 generator.

A UUID and a GUID are the same thing: a 128-bit identifier, written as 32 hexadecimal digits, that two computers can create independently without colliding. UUID, Universally Unique Identifier, is the IETF's name. GUID, Globally Unique Identifier, is Microsoft's name for the identical value. The bits do not differ. This article walks through the RFC 9562 layout [rfc9562] and compares the three versions you meet in code: 1, 4 and 7.

Microsoft coined GUID for COM and carried it into .NET. The IETF standardized the same structure as UUID. The two names never differ in the value. They differ only in *text formatting*, and sometimes in *byte order* inside certain Microsoft tools, as the last section covers.

What is a GUID, and how does it relate to a UUID?

A GUID is Microsoft's term for a 128-bit identifier that labels objects, COM interfaces, classes and database rows without a central authority issuing numbers. It is the same structure, bit for bit, that the IETF calls a UUID. The format goes back to Apollo's Network Computing System from 1987, which Microsoft adopted [wikipedia-uuid]. Both names describe a value like f47ac10b-58cc-4372-a567-0e02b2c3d479.

A UUID is 128 bits, usually written as 32 hex digits in five groups separated by hyphens (8-4-4-4-12). Two fields are reserved. The version, 4 bits, names the generation method. The variant, 2 to 3 bits, names the layout rules. Almost all code uses the IETF variant, whose bits read 10x.

FieldBitsHex positionPurpose
time_low / random321-8Low time field (v1/v6) or random data (v4)
time_mid / random169-12Mid time field or random data
version413Version number 1-8; this nibble is fixed
time_high / random1214-16Remaining time field or random data
variant2-317Variant marker; top bits are 10x for IETF
clock_seq / random13-1417-20Clock sequence (v1) or random data
node / random4821-32MAC-derived node (v1) or random data
The 128-bit UUID layout for the IETF variant (RFC 9562 field positions).

What is RFC 9562, the current UUID specification?

RFC 9562 is the IETF's UUID specification, published in May 2024. It replaces RFC 4122 from 2005 [rfc9562][rfc4122] and does three things. It tightens the wording for versions 1 to 5. It adds versions 6, 7 and 8. And it gives explicit rules on randomness and time ordering, so identifiers can sort by creation time.

Versions 6 and 7 fix two problems with the original version 1. Version 1 was reliable for uniqueness, but it sorted in a confusing byte order. It also embedded the machine's network MAC address, which leaked hardware identity. The newer versions keep the time order and drop the leak. Version 8 is a free-form slot for custom layouts.

This specification defines UUIDs (Universally Unique IDentifiers) -- also known as GUIDs (Globally Unique IDentifiers) -- and a Uniform Resource Name namespace for UUIDs. A UUID is 128 bits long and is intended to guarantee uniqueness across space and time.
— RFC 9562, Universally Unique IDentifiers (UUIDs), IETF, May 2024

How do UUID versions 1, 4, and 7 compare?

Versions 1, 4 and 7 cover almost everything you meet in practice. Version 1 is the classic timestamp-plus-MAC design. Version 4 is 122 random bits and the default in most languages. Version 7 puts a 48-bit millisecond timestamp in front of 74 random bits, so it sorts by creation time. The table shows where they differ on the properties that decide a design.

PropertyVersion 1Version 4Version 7
Source of bitsTimestamp + clock seq + node122 random bits48-bit Unix ms time + 74 random bits
Random bits~14 (clock seq)12274
Sortable by creation timeNo (mixed byte order)NoYes
Reveals generation timeYesNoYes (millisecond)
Reveals machine identityYes (MAC address)NoNo
Collision riskVery lowNegligibleNegligible
Needs a clockYesNoYes
Best useLegacy systemsGeneral-purpose IDs, tokensDatabase primary keys
UUID versions 1, 4, and 7 across the properties developers care about.

Three rows deserve a closer look. Version 1 exposes the machine's MAC address and a timestamp. RFC 9562 says implementations should use version 7 instead of versions 1 and 6 where possible [rfc9562]. Version 4 spends 122 of its 128 bits on randomness, so it tells an observer nothing about when or where it was made. Version 7 trades some privacy for order: anyone holding a v7 value can read its creation time to the millisecond.

Why is version 4 the safe default?

Version 4 is the safe default because it needs no clock, no coordination and no MAC address, and it reveals nothing about its origin. With 122 random bits, the birthday bound puts an even chance of one collision at about 2.7 quintillion values: a billion per second for about 86 years. That privacy matters when an identifier appears in a URL, an email or a log a third party can read.

One caveat: a v4 UUID is only as unique as the random number generator behind it. Draw those 122 bits from a cryptographically secure source, not a basic pseudo-random function, or the guarantee weakens [nist-rng]. In JavaScript that means crypto.randomUUID().

Why is version 7 rising for database primary keys?

Version 7 is rising for primary keys because it keeps inserts together. A B-tree index keeps rows sorted. A random v4 key lands each insert in an unpredictable place, touching cold pages and splitting index pages again and again. A v7 key starts with a 48-bit millisecond timestamp. New rows sort near each other at the end of the index, so recent pages stay in cache.

The payoff is largest when the storage engine *clusters* table data by primary key. In MySQL InnoDB, the clustered index stores rows in primary-key order. A random v4 key inserts rows in random positions and fragments the table [innodb-index]. A time-ordered v7 key avoids that. PostgreSQL keeps the primary key in a separate index instead of ordering the table itself. The gain is smaller there, but still real for index size and caching.

DimensionVersion 4 (random)Version 7 (time-ordered)
Insert position in indexRandom, scatteredSequential, near tail
Index page splitsFrequentRare
Cache locality on insertPoor (cold pages)Good (hot pages)
InnoDB clustered index fitPoorGood
Range scan by creation timeNot possiblePossible
Reveals creation timeNoYes (consider before exposing)
Cross-system generationTrivialTrivial
Version 7 versus version 4 as a database primary key.

The cost of v7 is privacy. It encodes the creation time, so publishing a v7 value lets anyone read when a record was made. Comparing two values even reveals how fast records are created. If a record's age is sensitive, keep v7 internal and show the outside world a separate v4 or an opaque slug.

How do you read the parts of a v7 UUID?

Take the v7 value 018f9d4e-7b2a-7c3d-9e1f-a2b3c4d5e6f7. Its first 48 bits, in hex, are 018f9d4e7b2a. That is 1,716,331,117,354 milliseconds, which decodes to 21 May 2024 at 22:38 UTC. The 7 that starts the third group is the version, and the 9 that starts the fourth confirms the IETF variant. In a v4 value, those first 48 bits are random and decode to nothing.

What GUID-specific quirks should I know about?

The two GUID quirks that trip people up are braces and byte order. Neither changes the underlying value. The Windows registry and some COM APIs wrap GUIDs in braces, like {f47ac10b-58cc-4372-a567-0e02b2c3d479}. And when a GUID is stored as binary, some Microsoft components write the first three groups in little-endian byte order and the last two in big-endian.

That mix bites when you treat a stored GUID as a flat 16-byte array. A round trip through such a system can reorder bytes and break an equality check. Before comparing a database GUID with a string, normalize both the text format and the byte order.

StyleExampleWhere seen
Canonical (IETF)f47ac10b-58cc-4372-a567-0e02b2c3d479RFC 9562, most APIs
Braced (Microsoft){f47ac10b-58cc-4372-a567-0e02b2c3d479}Windows registry, COM
No hyphensf47ac10b58cc4372a5670e02b2c3d479Compact storage, URLs
URN namespaceurn:uuid:f47ac10b-58cc-4372-a567-0e02b2c3d479RDF, semantic web
Uppercase hexF47AC10B-58CC-4372-A567-0E02B2C3D479Some Microsoft output
Common UUID/GUID text representations of the same value.

What does our generator produce, and how should you use it?

Our UUID generator emits well-formed version-4 values, with no timestamp and no machine identity. Be clear about what it is. It runs on the site's seeded test-data engine, and each seed is reduced to a 32-bit number. So its values do not carry 122 bits of independent randomness, and they can repeat. That suits the purposes we support: software testing, QA fixtures, form-filling and seeding development databases. Do not use it for production identifiers.

For production keys, generate UUIDs inside your application or database. PostgreSQL ships gen_random_uuid() for version 4 and, since version 18, uuidv7() [pg-uuid]. Most languages have a secure built-in, such as crypto.randomUUID() in JavaScript. Use our output for test data, and reach for the password generator when you need a secret instead of an identifier.

Which UUID version should I choose? A quick decision guide

  • Need a general-purpose unique ID that reveals nothing? Use version 4, from a secure random source. It is the default for good reasons.
  • Building a primary key on an engine that orders rows by key, like InnoDB? Use version 7, but keep it internal if creation time is sensitive.
  • Maintaining a legacy system on version 1? Leave it, but avoid v1 for new work because it exposes the MAC address.
  • Need a secret, token or password? A UUID is the wrong tool. Use the password generator.
  • Generating test data? Our UUID generator produces well-formed version-4 values for exactly this.

References & sources

  1. RFC 9562: Universally Unique IDentifiers (UUIDs) — IETF
  2. RFC 4122: A Universally Unique IDentifier (UUID) URN Namespace — IETF
  3. Universally unique identifier — Wikipedia
  4. Clustered and Secondary Indexes (InnoDB) — Oracle MySQL Documentation
  5. Recommendation for Random Number Generation Using Deterministic Random Bit Generators (SP 800-90A Rev. 1) — NIST
  6. UUID Functions (PostgreSQL 18) — PostgreSQL Global Development Group

Frequently asked questions

What is a UUID?

A UUID (universally unique identifier) is a 128-bit value written as 32 hexadecimal digits in five hyphen-separated groups (8-4-4-4-12), such as 3f2b8c1e-9d4a-4b6f-8e2a-1c7d5e9f0a3b. RFC 9562 defines the format. GUID is Microsoft's name for the same thing.

Is a GUID the same as a UUID?

Yes. GUID, Globally Unique Identifier, is Microsoft's name for the same 128-bit value the IETF calls a UUID. The bit layout, version field and variant field are identical. A GUID from .NET and a UUID from a Linux tool follow the same RFC 9562 rules.

What is the difference between UUID v4 and v7?

Version 4 is almost entirely random, with no time inside. Its values cannot be sorted by age and scatter across a database index. Version 7 starts with a 48-bit Unix timestamp in milliseconds. Its values sort by creation time and land near each other in a B-tree index, which means fewer page splits.

Should I use UUID v7 for a database primary key?

Often yes, if your storage engine orders rows by primary key, as MySQL InnoDB does, or otherwise benefits from sequential inserts. Version 7's time order keeps new rows close together in the index. Use v4 when you want identifiers that are unpredictable and reveal no time.

Which UUID version should I use by default?

Version 4. It is widely supported and needs no clock or coordination. It reveals nothing about when or where it was made, and it is what most libraries produce by default. Reach for v7 mainly when you have measured an index hotspot in your database.

What is RFC 9562?

RFC 9562 is the IETF's May 2024 specification for UUIDs. It replaces RFC 4122 from 2005, restates versions 1 to 5, and adds versions 6, 7 and 8 for time-ordered and custom UUIDs.

Can two UUIDs ever collide?

It is possible but extremely unlikely for a properly random version 4. With 122 random bits, the birthday bound puts an even chance of one collision at about 2.7 quintillion UUIDs. That is a billion per second for about 86 years. A generator with less real randomness, such as a seeded test generator, can repeat far sooner.

Update history

  1. Added a plain answer to what a UUID is.
  2. Corrected what our UUID tool is (a seeded test generator, not a source of 122 independent random bits), fixed the collision estimate to 86 years and RFC 9562's actual recommendation, replaced a database citation, and rewrote the prose in shorter sentences.
  3. Replaced an invented author persona in the byline with the site's real author.
  4. Retitled for the query 'UUID vs GUID: versions 1, 4, 7'.
  5. Published, covering the RFC 9562 layout and versions 1, 4 and 7.

More on technical identifiers

Put this to work