A UUID is a 128-bit identifier standardized in RFC 9562 that provides guaranteed uniqueness across distributed computer systems without central coordination.
A Universally Unique Identifier (UUID)—also referred to as a Globally Unique Identifier (GUID) within Microsoft ecosystems—is a standardized 128-bit (16-byte) label governed by IETF RFC 9562 (superseding RFC 4122). UUIDs enable distributed computing systems to generate globally collision-resistant identifiers autonomously without consulting a central coordinating registry, server, or relational database sequencer.
Generate, format, and inspect cryptographically secure v4 and time-ordered v7 identifiers in bulk with our UUID Generator tool.
A canonical UUID is rendered as a 36-character hexadecimal string broken into five hyphen-separated segments following the 8-4-4-4-12 format:
time_low time_mid ver time_hi var clock_seq node (MAC or Random)
Canonical UUID: f47ac10b - 58cc - 4 e0e - 8 e78 - 4817a874b369
(8 chars) (4 chars) (4 chars) (4 chars) (12 chars)
Within the 128-bit payload, two fields explicitly dictate the identifier's internal architecture:
4 for random, 7 for time-ordered).8, 9, a, or b, representing binary 10xx).| Version | Core Mechanism | Predictable? | Privacy Risk | Primary Best Use Case |
|---|---|---|---|---|
| v1 | 60-bit timestamp + MAC address | Yes | High (Leaks hardware MAC & time) | Legacy systems only; avoid for new architectures. |
| v3 | MD5 hash of a namespace + name | Deterministic | Low | Reproducible deterministic IDs from names (legacy). |
| v4 | 122 cryptographically random bits | No | Zero | Ephemeral tokens, session keys, distributed entities. |
| v5 | SHA-1 hash of a namespace + name | Deterministic | Low | Reproducible deterministic IDs (RFC 9562 standard). |
| v6 | Reordered v1 for B-tree sortability | Yes | High (Retains MAC address) | Transitionary format superseded by v7. |
| v7 | 48-bit Unix epoch ms + random bits | Monotonic | Zero | Modern Gold Standard for Database Primary Keys. |
| v8 | Custom vendor-defined bit layouts | Varies | Varies | Experimental and proprietary enterprise protocols. |
For decades, UUID v4 has been the default identifier in web frameworks. However, storing UUID v4 as a primary key in high-throughput relational databases (PostgreSQL, MySQL InnoDB, SQL Server) triggers catastrophic performance degradation:
Relational databases index primary keys using B-Trees. Because UUID v4 is completely random, new records are inserted at unpredictable random locations throughout the index:
UUID v4 Insertion (Random Chaos):
Insert A (Page 1) ──► Insert B (Page 94) ──► Insert C (Page 12) ──► Insert D (Page 73)
Result: Massive B-Tree fragmentation, high disk I/O, slow writes.
UUID v7 Insertion (Chronological Order):
Insert A (Page 1) ──► Insert B (Page 1) ──► Insert C (Page 1) ──► Insert D (Page 2)
Result: Sequential appends, maximum caching efficiency, zero index bloat.
Published in 2024, UUID v7 combines a 48-bit millisecond Unix timestamp with 74 bits of cryptographically random data. This guarantees that newly created IDs are naturally sorted in chronological order while maintaining total privacy and uniqueness without leaking hardware addresses.
UUID v4 reserves 6 bits for version and variant metadata, leaving 122 bits of true entropy ($2^{122} \approx 5.3 \times 10^{36}$ unique values).
Based on the Birthday Paradox:
// Generate cryptographically secure UUID v4 natively
const uuidV4 = crypto.randomUUID();
console.log("UUID v4:", uuidV4);
// Example output: "c9a646d3-9c61-4cd9-bf12-7258163da9d4"
// Basic RFC 9562 UUID v7 generator in JavaScript
export function generateUuidV7(): string {
const timestamp = BigInt(Date.now());
const randBytes = crypto.getRandomValues(new Uint8Array(10));
// 48-bit timestamp in big-endian
const timeHex = timestamp.toString(16).padStart(12, '0');
// Format with version 7 (0x7) and variant (0x80)
const part3 = `7${Array.from(randBytes.slice(0, 2)).map(b => b.toString(16).padStart(2, '0')).join('').slice(1)}`;
const varByte = (randBytes[2] & 0x3f) | 0x80;
const part4 = `${varByte.toString(16).padStart(2, '0')}${randBytes[3].toString(16).padStart(2, '0')}`;
const part5 = Array.from(randBytes.slice(4, 10)).map(b => b.toString(16).padStart(2, '0')).join('');
return `${timeHex.slice(0, 8)}-${timeHex.slice(8, 12)}-${part3}-${part4}-${part5}`;
}
import uuid
# Generate UUID v4
id_v4 = uuid.uuid4()
print("UUID v4:", str(id_v4))
# Check version and variant
print("Version:", id_v4.version) # 4
print("Variant:", id_v4.variant) # specified in RFC 4122
Technically, they are identical: both are 128-bit identifiers compliant with RFC standards. GUID (Globally Unique Identifier) is Microsoft's historical nomenclature, while UUID (Universally Unique Identifier) is the international standard defined by ISO and the IETF.
For distributed database primary keys, UUID v7 is vastly superior. Its chronological millisecond timestamp allows database storage engines to perform sequential B-tree writes, eliminating the disk page fragmentation, cache misses, and query slowdowns inherent to UUID v4.
UUID v1 derives its trailing 48 bits from the physical network card's IEEE 802 MAC address and its leading bits from the system clock. Anyone inspecting a v1 UUID can identify the specific physical computer that created it and the exact microsecond of its creation.
A UUID occupies 16 bytes when stored in a native binary format (UUID type in PostgreSQL, BINARY(16) in MySQL). If stored as a plain hyphenated string (VARCHAR(36)), it consumes 36 bytes plus length byte overhead—more than double the binary footprint.
Free, browser-based utilities to test, generate, and inspect Universally Unique Identifier (UUID / GUID) payloads directly.