How to generate a GUID
- A new GUID appears at the top as soon as the page loads. Press Copy to use it, or the arrow to make a new one.
- Need more? Drag How many to create up to 1,000 at once, then Copy all or Download them as a text file.
- Pick the version: v4 for random IDs, v7 for database keys that sort by creation time, or v5 to turn a name into the same UUID every time. ULID and NanoID give shorter, URL-safe IDs.
- Match the format your code expects: uppercase and braces for Windows and .NET, no hyphens for compact storage, quotes and commas to paste into an array or SQL
IN (…)list. - Need it shorter or safe for a URL? Set Encoding to Base64 or Base64url to encode the 16 raw bytes, or URL-encoded to escape the braces and quotes.
What is a GUID?
A GUID (globally unique identifier), also called a UUID, is a 128-bit number used to label something without asking a central authority for the next free number. It's written as 32 hexadecimal digits in five groups, 8-4-4-4-12:
f47ac10b-58cc-4372-a567-0e02b2c3d479
Two digits carry meaning. The first digit of the third group (4 above) is the version, which says how the GUID was made. The first digit of the fourth group (a) is the variant; 8, 9, a or b means the standard layout. Everything else is random bits, a timestamp or a hash, depending on the version.
UUID versions compared
| Version | Built from | Sortable? | Typical use |
|---|---|---|---|
| v1 | Timestamp + device MAC address | No | Legacy systems; leaks the machine and time |
| v3 | MD5 of a namespace + name | No | Legacy; use v5 instead |
| v4 | 122 random bits | No | General-purpose IDs, the most common choice |
| v5 | SHA-1 of a namespace + name | No | The same ID for the same name, across systems |
| v6 | Reordered v1 timestamp | Yes | Upgrading v1 systems |
| v7 | Unix time in milliseconds + random bits | Yes | Database primary keys, event and log IDs |
| v8 | Your own layout | Depends | Custom or experimental formats |
Versions 6, 7 and 8 were added by RFC 9562 in May 2024, which replaced the original RFC 4122. If you aren't sure, use v4. If the IDs will be a database's primary key, use v7: because they increase over time, new rows are written next to each other in the index instead of all over it, which keeps inserts fast and indexes small.
Common GUID formats
| Format | Example | Where you see it |
|---|---|---|
| Standard | f47ac10b-58cc-4372-a567-0e02b2c3d479 | Most languages, APIs, PostgreSQL |
| Uppercase | F47AC10B-58CC-4372-A567-0E02B2C3D479 | SQL Server, Windows tools |
| Braces | {F47AC10B-58CC-4372-A567-0E02B2C3D479} | Windows Registry, COM, Visual Studio |
| No hyphens | f47ac10b58cc4372a5670e02b2c3d479 | Compact storage, file names |
| URN | urn:uuid:f47ac10b-58cc-4372-a567-0e02b2c3d479 | XML and standards documents |
All of these are the same value. GUID comparison is case-insensitive, and our GUID validator accepts every format above.
Base64, Base64url and URL-encoded GUIDs
The Encoding option changes how the 128 bits are written, not the ID itself. Base64 and Base64url encode the 16 raw bytes in standard (RFC 9562) byte order, so the result is shorter than the 36-character text form:
| Encoding | Example | Length | Use it for |
|---|---|---|---|
| Base64 | 9HrBC1jMQ3KlZw4CssPUeQ== | 24 | JSON payloads, binary columns shown as text |
| Base64url (RFC 7515) | 9HrBC1jMQ3KlZw4CssPUeQ | 22 | URLs, file names, JWT claims: no +, / or padding |
| URL-encoded | %7BF47AC10B-58CC-4372-A567-0E02B2C3D479%7D | varies | A braced or quoted GUID inside a query string |
.NET's Guid.ToByteArray() stores the first three groups little-endian, so
Convert.ToBase64String(guid.ToByteArray()) gives a different string for the same GUID. Use
guid.ToByteArray(bigEndian: true) (.NET 8+) to match the output here.
ULID and NanoID: shorter alternatives
A ULID holds the same 128 bits as a UUID (a 48-bit millisecond timestamp and
80 random bits) in 26 characters of Crockford Base32, such as 01JCXQ7Z8K4W3N5R2T6V9Y0B1D. It sorts by
time like v7 and needs no escaping in a URL. A NanoID is just random
characters, 21 by default from a 64-symbol URL-safe alphabet, which gives 126 random bits: about as many as a v4
UUID in 15 fewer characters. Use the dedicated pages for a custom alphabet or to convert a ULID to a UUID.
How unique is a GUID?
A v4 GUID has 122 random bits, giving 5.3 × 1036 possible values. By the birthday problem, you'd need to
generate about 2.7 quintillion GUIDs before there's even a 50% chance that two are the same. At a
billion GUIDs a second, that takes around 86 years. In real systems a duplicate is far more likely to come from a bug,
such as a weak random generator or copying a value twice, than from chance. This page uses the browser's
cryptographically secure generator, crypto.getRandomValues.
Generate a GUID in code
| Language | Random (v4) | Time-ordered (v7) |
|---|---|---|
| JavaScript (browser, Node.js) | crypto.randomUUID() | uuid package: v7() |
| Python | uuid.uuid4() | uuid.uuid7() (Python 3.14+) |
| C# / .NET | Guid.NewGuid() | Guid.CreateVersion7() (.NET 9+) |
| Java | UUID.randomUUID() | A library such as java-uuid-generator |
| Go | uuid.New() (google/uuid) | uuid.NewV7() (google/uuid) |
| PostgreSQL | gen_random_uuid() | uuidv7() (PostgreSQL 18+) |
| SQL Server | NEWID() | NEWSEQUENTIALID() (sequential, not v7) |
Use one ID for the whole lifetime of a record
Suppose a customer submits a support form and your system writes the request to a database, then queues a notification. Generate the identifier once when the request is created. Pass that same value into the database row, the queued message and the receipt shown to the customer. If the notification is retried, keeping the existing ID lets you tie the retry to the original request. Generating a fresh value at every step makes it harder to tell which records belong together.
Store the ID with a uniqueness constraint where your data model requires unique rows. Decide separately how to recognize duplicate submissions. A unique UUID tells you that two identifiers are different. A person can submit the same form twice and still receive two perfectly valid UUIDs.
Check which version the application expects before copying a result from this page. A test record that exercises a random UUID path should use v4. If an integration checks for the time-ordered layout in v7, use a v7 sample and read it using that version's rules. Test the canonical lowercase, hyphenated form first if you control both sides of an HTTP interface.
Check the interchange format before debugging the ID
If one system sends a hyphenated UUID and another sends Base64, confirm that the contract describes the byte order as well as the spelling. Start with one fixed example and decode it on both sides. Compare the canonical UUID text after decoding. This isolates a byte-order mismatch from a problem in how either service generates new IDs.
Settle on a format for the boundary between services and keep the native UUID type where your database supports the operations you need. Some storage engines sort UUIDs differently. Before adopting v7 for index locality, observe the actual sort order and write pattern in your target database with representative records.
Treat IDs in public URLs as labels for records. If a receipt, invoice or user profile requires permission, verify that the application checks the signed-in user's access every time it loads the object. UUID format validation only answers questions about the identifier's shape and version. A request can carry a valid identifier and still lack permission to read the associated record. RFC 9562 UUID specification.
Comments 0
No comments yet.