Developer Tools

GUID vs UUID: Does the Difference Actually Matter?

6 min
By
GUID vs UUID: Does the Difference Actually Matter?

Photo by Pexels

A GUID is a UUID. A UUID is a GUID. Except when Microsoft does something different, which is often enough to matter.

The terms get used interchangeably, and most of the time that is fine. But if you are passing identifiers between a .NET system and anything else, the difference will bite you. It bit me on a project that synced data between a C# backend and a Python API. The UUIDs matched as strings but not as bytes. Here is why.

The Origin Story

UUID is defined by RFC 4122, published in 2005. GUID is Microsoft's name for the same concept, dating back to COM in the 1990s. Both are 128-bit identifiers. Both use the same format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. Both support the same versions (v1, v3, v4, v5).

So far, identical.

The Byte Ordering Problem

Here is where it breaks. When Microsoft stores a GUID in memory or in a SQL Server UNIQUEIDENTIFIER column, the first three fields are stored in little-endian byte order. The last two fields are stored in big-endian.

This means the GUID f47ac10b-58cc-4372-a567-0e02b2c3d479 is stored in memory as:

0b c1 7a f4 cc 58 72 43 a5 67 0e 02 b2 c3 d4 79

Not:

f4 7a c1 0b 58 cc 43 72 a5 67 0e 02 b2 c3 d4 79

If you read that GUID from SQL Server into Python using a raw byte protocol, you get a different UUID than the string representation suggests. The string is the same. The bytes are reversed for the first 8 bytes. This is the GUID vs UUID difference that actually matters.

When This Bites You

**Binary protocols.** If you serialize a GUID to bytes in C# and deserialize as a UUID in Java, Python, or Go, the first three groups come out reversed. The UUIDs do not match.

**SQL Server replication to non-Microsoft systems.** SQL Server's UNIQUEIDENTIFIER uses the Microsoft byte ordering. Replicating to Postgres or MySQL without string conversion scrambles the UUIDs.

**File formats and binary storage.** Any binary format written by a Microsoft tool (Office files, Windows registry exports, .NET binary serialization) stores GUIDs in this order.

The Fix

Always pass GUIDs as strings at system boundaries. The string representation f47ac10b-58cc-4372-a567-0e02b2c3d479 is identical across all platforms. Only the in-memory byte layout differs. If you convert to bytes, do it on one side and convert from the string on the other.

csharp // C# — this is fine, the string is canonical Guid g = Guid.Parse("f47ac10b-58cc-4372-a567-0e02b2c3d479"); string s = g.ToString(); // 'f47ac10b-58cc-4372-a567-0e02b2c3d479'

// This is the problem — byte order is Microsoft's byte[] bytes = g.ToByteArray(); // [0b, c1, 7a, f4, cc, 58, 72, 43, a5, 67, 0e, 02, b2, c3, d4, 79]

## GUID for COM Component

The term GUID originates from COM (Component Object Model). Every COM interface, class, and type library gets a GUID that identifies it uniquely in the Windows registry. The IID_IDispatch interface has GUID 00020400-0000-0000-c000-000000000046. The CLSID_ShellLink class has GUID 00021401-0000-0000-c000-000000000046.

If you do Windows development, COM GUIDs are everywhere. The registry keys HKEY_CLASSES_ROOT\CLSID and HKEY_CLASSES_ROOT\Interface are full of them. These are v1 UUIDs generated by uuidgen or CoCreateGuid.

GUID Generator Online

If you need a GUID quickly — for a COM component, a Windows registry entry, a .NET project, or just a UUID — use a guid generator online. Our UUID generator produces RFC 4122 compliant UUIDs that work as GUIDs in any Microsoft context. The output is the same string format.

The Microsoft GUID Quirks Summary

| Aspect | RFC 4122 UUID | Microsoft GUID | |--------|---------------|----------------| | String format | Identical | Identical | | Byte order (first 3 groups) | Big-endian | Little-endian | | Byte order (last 2 groups) | Big-endian | Big-endian | | Default version | v4 | v4 | | SQL Server storage | N/A | UNIQUEIDENTIFIER (little-endian) |

The Practical Answer

For 95% of developers, GUID and UUID are interchangeable. Use the string representation. Pass strings across system boundaries. Never pass raw bytes unless both sides agree on the byte order. If you are in the 5% that does binary interop with Microsoft systems, now you know what to check.

Generate GUIDs and UUIDs at our UUID generator. For the version breakdown, read UUID v1 vs v4 vs v5. For database usage, see UUIDs as primary keys.

Frequently Asked Questions

Is a GUID the same as a UUID?

Yes, in string format. Both are 128-bit identifiers following the same format. The difference is in byte ordering: Microsoft stores the first three groups in little-endian, which matters for binary serialization.

Why do my GUIDs not match after passing them as bytes to Python?

Microsoft stores GUID bytes in little-endian order for the first three groups. Python's uuid module expects big-endian. Pass GUIDs as strings across the boundary, not bytes, to avoid this.

What is a GUID used for in COM?

COM uses GUIDs to uniquely identify interfaces, classes, and type libraries in the Windows registry. Every COM component has a CLSID and every interface has an IID, both GUIDs.

Try NovelCrypt Tools

Experience military-grade encryption for your sensitive data. Create self-destructing messages, encrypt files, or explore our experimental lab tools.

Explore NovelCrypt