What is a UUID?
UUID (Universally Unique Identifier) is a 128-bit number used to uniquely identify information in computer systems. Defined by RFC 4122, UUIDs are designed to be unique across space and time without requiring a central registration authority.
The standard UUID format is 32 hexadecimal characters displayed as 5 groups separated by hyphens: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12).
UUID Structure
xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
Breakdown:
• Total: 128 bits (32 hex characters)
• Position 13: Always "4" (version indicator)
• Position 17 (y): 8, 9, a, or b (variant indicator)
• All other positions: Random hex (0-9, a-f)
Example:
550e8400-e29b-41d4-a716-446655440000
UUID Versions
- Version 1: Based on timestamp and MAC address. Can reveal when/where it was created.
- Version 3: MD5 hash of namespace + name. Deterministic—same input = same UUID.
- Version 4: Random. Most common. Generated here. 122 random bits.
- Version 5: SHA-1 hash of namespace + name. More secure than v3.
- Version 7: Timestamp-based with random bits. Sortable and K-sortable friendly.
UUID vs GUID
UUID and GUID (Globally Unique Identifier) are functionally identical. "GUID" is Microsoft's term used in Windows and .NET, while "UUID" is the standard term used in RFCs and most other contexts. Both use the same format and generation algorithms.
Collision Probability
UUID v4 has 122 random bits (128 total minus 6 fixed bits for version/variant). The probability of collision is astronomically low:
To have a 50% chance of collision, you'd need to generate approximately 2.7 × 10^18 UUIDs.
At 1 billion UUIDs per second, that would take about 85 years!
When to Use UUIDs
- Database primary keys: In distributed databases where auto-increment IDs would conflict.
- API identifiers: For resources in REST APIs (e.g., /users/550e8400-e29b-41d4-a716-446655440000).
- Session tokens: Uniquely identify user sessions across servers.
- File naming: Avoid conflicts in uploaded files or generated documents.
- Distributed systems: Generate IDs on multiple servers without coordination.
- Message queues: Uniquely identify messages across systems.
Benefits of This Generator
- RFC 4122 compliant: Generates valid UUID v4 per the official specification.
- Cryptographically secure: Uses crypto.randomUUID() when available.
- Bulk generation: Create up to 100 UUIDs at once.
- Format options: Uppercase and no-dashes variants available.
- Privacy safe: Generated locally in your browser, no server calls.
Frequently Asked Questions
Are these UUIDs truly random?
Yes. This generator uses the Web Crypto API (crypto.randomUUID() or crypto.getRandomValues()) which provides cryptographically secure random numbers, suitable for security-sensitive applications.
Can I use these UUIDs in production?
Yes. These are valid, RFC 4122 compliant UUID v4 identifiers. They're as unique and random as UUIDs generated by any programming language's standard library.
Should I use UUIDs or auto-increment IDs?
Use auto-increment for simple, single-server applications. Use UUIDs for distributed systems, when IDs shouldn't reveal information (like record count), or when you need to generate IDs before database insertion.
Why do UUIDs have dashes?
Dashes improve human readability by breaking the 32-character string into smaller groups. They're optional—many systems accept UUIDs with or without dashes. The dashes don't add any information.
What is a nil UUID?
The nil UUID is all zeros: 00000000-0000-0000-0000-000000000000. It's used to represent "no UUID" or as a placeholder, similar to null in programming languages.
Can UUIDs be sorted chronologically?
UUID v4 (random) cannot be sorted by creation time. For sortable UUIDs, use UUID v1 (timestamp-based) or the newer UUID v7 which combines timestamps with randomness.
