Free .NET developer tool
GUID Generator for .NET
Random version 4 GUIDs like Guid.NewGuid(), or time-ordered version 7 like Guid.CreateVersion7() — one or a thousand, in every ToString format.
Runs entirely in your browser — nothing you paste is uploaded.
GUIDs are generated in your browser with crypto.getRandomValues.
Inspect a GUID
Paste any GUID in any format to see its version, variant and embedded timestamp.
Version 7RFC 9562Created 2025-10-10 17:45:32.992 UTC
Version 7: Unix-millisecond timestamp + random — what Guid.CreateVersion7() produces in .NET 9+.
| D | 0199cf3a-5e40-7b2c-9d1e-4f6a8b2c1d3e |
|---|---|
| N | 0199cf3a5e407b2c9d1e4f6a8b2c1d3e |
| B | {0199cf3a-5e40-7b2c-9d1e-4f6a8b2c1d3e} |
| P | (0199cf3a-5e40-7b2c-9d1e-4f6a8b2c1d3e) |
| X | {0x0199cf3a,0x5e40,0x7b2c,{0x9d,0x1e,0x4f,0x6a,0x8b,0x2c,0x1d,0x3e}} |
Creating GUIDs in C#
Guid.NewGuid() returns a random version 4 GUID from the operating system's cryptographic generator. .NET 9 added Guid.CreateVersion7(), whose leading 48 bits are a Unix millisecond timestamp — values created later sort later, which keeps B-tree index inserts at the end instead of scattered across pages.
Guid id = Guid.NewGuid(); // version 4, random
Guid ordered = Guid.CreateVersion7(); // version 7, time-ordered (.NET 9+)
Guid at = Guid.CreateVersion7(DateTimeOffset.UtcNow);
string d = id.ToString(); // 6f1c2a8e-3b4d-4e5f-9a0b-1c2d3e4f5a6b
string n = id.ToString("N"); // 6f1c2a8e3b4d4e5f9a0b1c2d3e4f5a6b
string b = id.ToString("B"); // {6f1c2a8e-3b4d-4e5f-9a0b-1c2d3e4f5a6b}
bool ok = Guid.TryParse(input, out Guid parsed);
int version = parsed.Version; // .NET 9+: 4 or 7 (or other)GUID primary keys with Entity Framework Core
For PostgreSQL and most other databases, version 7 values make good clustered keys. SQL Server is the exception: it orders uniqueidentifier by the last six bytes first, where a v7 GUID keeps its random bits, so use NEWSEQUENTIALID() there.
// EF Core 9+ generates version 7 values client-side for Guid keys on most providers.
public class Order
{
public Guid Id { get; set; } = Guid.CreateVersion7();
}
// SQL Server sorts uniqueidentifier by its LAST bytes, so v7 still fragments a
// clustered index there; let the database generate sequential values instead:
modelBuilder.Entity<Order>()
.Property(o => o.Id)
.HasDefaultValueSql("NEWSEQUENTIALID()");Frequently asked questions
What is the difference between GUID version 4 and version 7?
A version 4 GUID is 122 random bits, which is what Guid.NewGuid() returns. A version 7 GUID, created with Guid.CreateVersion7() in .NET 9 and later, starts with a 48-bit Unix millisecond timestamp followed by random bits, so values created later sort later. That ordering makes v7 a much better database key, because inserts land at the end of the index instead of at random pages.
Are version 7 GUIDs sequential in SQL Server?
Not when stored as uniqueidentifier. SQL Server sorts uniqueidentifier by its last six bytes first, while a v7 GUID puts its timestamp in the first six, so v7 values still fragment a clustered index. Use NEWSEQUENTIALID() for SQL Server-generated keys, or store v7 values as binary(16) or a string if you need them ordered. PostgreSQL’s uuid type does sort v7 values by time.
What do the N, D, B, P and X formats mean?
They are the format strings for Guid.ToString. D is the default 36-character form with hyphens, N drops the hyphens, B wraps the D form in braces, P wraps it in parentheses, and X writes it as a C-style hexadecimal initializer. Guid.Parse accepts all five; Guid.ParseExact requires the specific format.
Can two GUIDs ever collide?
In practice, no. A version 4 GUID has 122 random bits, so you would need to generate about 2.7 quintillion of them to reach a 50% chance of a single duplicate. Version 7 has 74 random bits per millisecond, which is still far beyond any realistic insert rate. Collisions in real systems come from bugs such as reusing a seeded Random, not from the format.