GUID and UUID are the same thing
GUID means Globally Unique Identifier, the name Microsoft uses for what the rest of the industry calls a UUID. Both are 128-bit values written as 32 hex digits. In Windows and .NET, Guid.NewGuid(), PowerShell's New-Guid and SQL Server's NEWID() create random (version 4) values, and the GUID generator here does the same. You can also choose version 7 for GUIDs that sort in time order.
GUID formats in Windows and .NET
| .NET format | Example | Setting here |
|---|---|---|
D (default) | 6F9619FF-8B86-D011-B42D-00C04FC964FF | Standard, uppercase on or off |
N | 6F9619FF8B86D011B42D00C04FC964FF | No hyphens |
B | {6F9619FF-8B86-D011-B42D-00C04FC964FF} | In braces |
P | (6F9619FF-8B86-D011-B42D-00C04FC964FF) | Braces, then change to parentheses by hand |
Note that .NET's Guid.ToString() writes lowercase by default, while the Windows registry, COM class ids (CLSID), installer product codes and Visual Studio project files traditionally show uppercase in braces. Both mean the same value, but some tools compare them as text, so keep one style.
Use a new GUID in .NET, PowerShell and SQL
// C#
Guid id = Guid.NewGuid();
string s = id.ToString("B").ToUpperInvariant(); // {XXXXXXXX-XXXX-...}
Guid v7 = Guid.CreateVersion7(); // .NET 9 and later
Guid.TryParse(text, out Guid parsed);
# PowerShell
[guid]::NewGuid()
New-Guid
-- SQL Server
SELECT NEWID(); -- random
-- column with a default: id uniqueidentifier DEFAULT NEWSEQUENTIALID()
// Visual Basic
Guid.NewGuid().ToString("B")
Things that surprise people
- Byte order. .NET stores the first three groups of a GUID in little-endian order.
Guid.ToByteArray()therefore returns bytes in a different order from the text. If you move GUIDs between .NET and a system that reads the text form as big-endian bytes (Java, Python, databases), convert them rather than copying bytes. - SQL Server sorting.
uniqueidentifiercolumns sort by the last 6 bytes first. A random GUID as a clustered key fragments the table, which is whyNEWSEQUENTIALID()exists. It can only be used as a column default, and it is predictable. - Empty GUID.
Guid.Emptyis00000000-0000-0000-0000-000000000000, the Nil UUID. It often means "not set", so do not generate it by accident. - Not a secret. A GUID is an identifier. Use cryptographic tokens for secrets.
Check a GUID
Paste a GUID in braces or without into the UUID validator to see if it is valid and which version it is. For UUIDs in other styles and versions, use the main UUID generator, or read the guide What is a UUID?