How to Generate a UUID
This UUID and GUID generator operates entirely client-side inside your browser across five tabs:
- 1. v4 (Random): Choose how many (1 to 1,000), the case, hyphens, braces, URN or Base64, then copy or download the list.
- 2. v7 (Time-Ordered): The same options for IDs that sort by creation time. The list presets give plain text, a SQL
INlist, JSON or CSV. - 3. v5 / v3 (Name): Supply a standard RFC 9562 namespace (DNS, URL, OID, X.500, or custom UUID) plus a UTF-8 name string to compute deterministic SHA-1 (v5) or MD5 (v3) UUIDs.
- 4. Validate & Convert: Paste a UUID or GUID to check its format, see its version and variant, convert it, and read the time inside v1, v6 and v7 values.
- 5. Nil & Max: Copy the empty (nil) GUID or the Max UUID.
Which UUID Version Should I Use?
RFC 9562 defines eight UUID versions, though most modern applications rely on three: v4, v7, and v5. Choosing the right version depends on whether you need unpredictability, database index locality, or deterministic repeatability.
| Version | Mechanism | Random / Hash Bits | Sortable? | Best Use Case |
|---|---|---|---|---|
| v4 | Cryptographic RNG | 122 random bits | No (random) | General IDs and URLs where creation time should stay hidden |
| v7 | 48-bit Unix ms + counter + RNG | Up to 74 bits | Yes (time-ordered) | Database primary keys, distributed logs, ordered event streams |
| v5 | SHA-1(namespace + name) | 122 hash bits | No (deterministic) | Idempotent IDs derived from URLs, domains, or external keys |
| v3 | MD5(namespace + name) | 122 hash bits | No (deterministic) | Legacy compatibility only; prefer v5 for new designs |
| v1 | Gregorian timestamp + MAC | 60-bit time + node | Byte-swapped | Legacy systems; leaks hardware MAC address and clock |
UUID v4 (Random) and Collision Odds
A version 4 UUID fills 122 of its 128 bits using a cryptographically secure pseudorandom number generator (here, Web Crypto crypto.getRandomValues). The remaining 6 bits are fixed: 4 bits hold the version nibble (0100, hex 4) and 2 bits hold the RFC variant (10, hex 8, 9, a, or b).
Because there are 2¹²² ≈ 5.3169 × 10³⁶ unique v4 values, accidental collisions are astronomically unlikely when using a proper CSPRNG. Under the birthday approximation p ≈ n² / (2 × 2¹²²), generating 1 billion (10⁹) v4 UUIDs yields a collision probability around 9.4 × 10⁻²⁰. Generating 5 × 10⁹ UUIDs gives roughly 2.35 × 10⁻¹⁸, and reaching a 50% collision chance requires approximately 2.71 × 10¹⁸ UUIDs—more than 100 million per second for 850 years.
UUID v7 (Time-Ordered) and Database Indexing
Random v4 UUIDs hurt write throughput on large relational tables because every insert lands at a random page in a B-tree index (PostgreSQL, MySQL InnoDB, SQL Server). Over millions of rows, random writes fragment the index and thrash the buffer pool.
Standardized in RFC 9562 §5.7, UUIDv7 solves this by putting a big-endian 48-bit Unix epoch millisecond timestamp in the first 6 bytes, followed by version 7 (0111), 12 bits of monotonic sub-millisecond counter or random bits, the 10 variant, and 62 random bits. When generating bulk v7 batches inside the same millisecond, this tool implements RFC 9562 monotonic counter incrementing (Method 1/2) so every generated ID strictly sorts after the previous one.
UUID v5 and v3 (Name-Based)
Name-based UUIDs produce the exact same 128-bit output every time you combine the same 16-byte namespace UUID with the same UTF-8 string. RFC 9562 defines four standard namespaces:
- DNS:
6ba7b810-9dad-11d1-80b4-00c04fd430c8 - URL:
6ba7b811-9dad-11d1-80b4-00c04fd430c8 - OID:
6ba7b812-9dad-11d1-80b4-00c04fd430c8 - X.500 DN:
6ba7b814-9dad-11d1-80b4-00c04fd430c8
For example, hashing the DNS namespace with www.example.com produces 2ed6657d-e927-568b-95e1-2665a8aea6a2 under v5 (SHA-1) and 5df41881-3aed-3515-88a7-2f4a814cf09e under v3 (MD5). Both can also accept any valid custom UUID as a namespace.
UUID vs GUID: Is There a Difference?
In everyday software engineering, UUID and GUID refer to the same 128-bit identifier specification. However, ecosystem conventions differ in presentation and binary layout:
- Canonical UUID (RFC 9562): Lowercase hexadecimal with hyphens (
550e8400-e29b-41d4-a716-446655440000), stored in network big-endian byte order. - Microsoft GUID: Often displayed uppercase or wrapped in curly braces (
{550E8400-E29B-41D4-A716-446655440000}). In Windows COM andSystem.Guidbyte arrays, the first three fields (time_low,time_mid,time_hi_and_version) are stored in little-endian order while the last 8 bytes remain big-endian.
Use the format options to output standard canonical UUIDs, uppercase GUIDs, braced GUIDs, 32-character hex strings without hyphens, or RFC URN format (urn:uuid:...).
UUID Format and Byte Layout
A canonical UUID consists of 32 hexadecimal characters (16 bytes = 128 bits) separated into five groups of lengths 8-4-4-4-12:
Here M (the 13th hex digit) indicates the version (e.g., 4 for random or 7 for time-ordered), and N (the 17th hex digit) encodes the variant. Standard RFC 4122 / RFC 9562 UUIDs have their two most significant bits of that byte set to 10, restricting N to 8, 9, a, or b.
Nil and Max UUIDs
RFC 9562 specifies two special sentinel UUIDs that bypass normal version/variant checks:
- Nil UUID:
00000000-0000-0000-0000-000000000000— all 128 bits set to zero, useful for representing an uninitialized or empty foreign-key placeholder without nullable columns. - Max UUID:
ffffffff-ffff-ffff-ffff-ffffffffffff— all 128 bits set to one, standardized in RFC 9562 §5.10 as an upper-bound sentinel for sorted range scans and pagination.
How to Validate a UUID
A naive 32-hex regex accepts invalid strings with bogus version or variant bits. To validate a standard RFC 9562 UUID strictly (versions 1 through 8, variant 10xx), match against:
Remember to allow the Nil and Max UUIDs explicitly if your application treats them as valid sentinels, and apply case-insensitive matching (/i) if Microsoft uppercase GUIDs are accepted.
Generate UUIDs in Code
Built-in standard library commands for new UUIDs. Databases differ in the version they return, so check yours:
JavaScript / Node.js / Browser
Python
C# / .NET
Java
SQL: PostgreSQL (13+), SQL Server, MySQL
PowerShell
Security Notes: CSPRNG & Predictability
UUIDs are designed for uniqueness, not secrecy. Version 1 leaks the host MAC address and creation timestamp; version 7 reveals millisecond creation timestamps; versions 3 and 5 are deterministic hashes of known inputs. Even version 4 (122 random bits) relies entirely on the quality of the underlying random number generator—always use Web Crypto crypto.getRandomValues or OS CSPRNGs rather than Math.random(), and do not use standard UUIDs as passwords or unhashed bearer secrets where cryptographic tokens are required.
Frequently Asked Questions
What is a UUID, and what does GUID stand for?
UUID stands for Universally Unique Identifier, and GUID for Globally Unique Identifier. It is a standardized 128-bit (16-byte) label defined in RFC 9562 (which replaced RFC 4122) and ISO/IEC 9834-8, written as 32 hexadecimal digits in five hyphen-separated groups (8-4-4-4-12) so distributed systems can create unique IDs without a central coordinator.
What is the difference between a UUID and a GUID?
Technically they share the same 128-bit RFC 9562 / ISO 9834-8 structure. "UUID" is the IETF/Linux/Postgres term formatted in lowercase hyphens, while "GUID" (Globally Unique Identifier) is Microsoft’s term in .NET, Windows, and SQL Server, often formatted in uppercase, wrapped in braces {...}, or stored in mixed-endian byte order for legacy COM APIs.
Are UUIDs truly unique — can two v4 UUIDs collide?
A UUIDv4 contains 122 random bits (6 bits are fixed for version 4 and variant 10), giving 5.3 × 10^36 possible values. By the birthday bound, you would need roughly 2.71 × 10^18 UUIDs (about one billion per second for 85 years) to reach a 50% chance of a single duplicate, assuming a cryptographic RNG.
Which UUID version should I use: v4, v7, or v5?
Use v7 for new database primary keys and event logs because its leading 48-bit Unix millisecond timestamp keeps B-tree inserts sequential. Use v4 when you want pure randomness with no embedded timestamp. Use v5 (SHA-1) when you need the exact same deterministic UUID every time for a given namespace and input name.
Why is UUIDv7 better for database primary keys than v4?
Random v4 UUIDs scatter inserts across the entire B-tree index, causing frequent page splits and cache misses on large tables. UUIDv7 places a monotonically increasing 48-bit millisecond timestamp in the most significant bits, so new rows append near the end of the index like an auto-increment integer while remaining globally unique.
What is the difference between UUIDv3 and UUIDv5?
Both are deterministic name-based versions that hash a 16-byte namespace UUID and a UTF-8 name string. Version 3 uses MD5 and version 5 uses SHA-1 cut to 128 bits. Both then replace 6 bits with the version and variant. RFC 9562 recommends v5 over v3 for new systems unless legacy compatibility requires MD5.
What is an empty (nil) GUID, and what is the Max UUID?
The Nil UUID (00000000-0000-0000-0000-000000000000) has all 128 bits set to zero and represents a null or unset identifier. RFC 9562 also defines the Max UUID (ffffffff-ffff-ffff-ffff-ffffffffffff) with all 128 bits set to one as an upper sentinel value for range queries.
How long is a UUID or GUID?
It is 128 bits (16 bytes): 32 hex digits, or 36 characters with the four hyphens. In Base64 it is 24 characters with padding, and 22 in base64url without it.
How do I generate a UUID in C#, Python, Java, SQL or PowerShell?
C#: Guid.NewGuid(). Python: uuid.uuid4(). Java: UUID.randomUUID(). PostgreSQL 13+: gen_random_uuid(). PowerShell: [guid]::NewGuid(). Each is shown as a code block in the section above.
How do I validate a UUID?
Check the 8-4-4-4-12 canonical layout with the version nibble (13th hex digit) in [1-8] and the variant nibble (17th hex digit) in [89ab]: ^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$ (case-insensitive), plus optional special checks for Nil and Max UUIDs. Paste any string into the Validate tab above to inspect its exact version, variant, and embedded v7 timestamp.
Can I generate UUIDs offline or in bulk?
Yes. Every generation mode (v4, v7, v5, v3, Nil/Max) and the validator run strictly inside your browser using Web Crypto (crypto.getRandomValues and crypto.subtle.digest). Generate up to 1,000 UUIDs in one click and copy or download them as .txt or .json without sending anything over the network.
Are UUIDs secure as passwords or API tokens?
Standard v7, v5, v3, and v1 UUIDs are not secret—they leak timestamps or deterministic inputs and should never be used as bearer tokens or passwords. Even v4 (122 random bits) relies on a cryptographic CSPRNG; if you need an authentication secret, generate a dedicated high-entropy token or password instead.
What changed in RFC 9562 compared to RFC 4122?
Published in May 2024, RFC 9562 obsoleted RFC 4122. It kept v1 through v5 unchanged, standardized time-ordered UUIDv6, epoch-ms UUIDv7, and custom/experimental UUIDv8, formalized the Max UUID (all F), and documented monotonic sub-millisecond counter methods for v7.
Related Developer Tools
- Password Generator: Generate high-entropy secret tokens and passwords (when a UUID should not be used as a secret).
- Comma Separator: Format bulk UUIDs or columns into SQL IN clauses, CSVs, and JSON arrays.