UUID / GUID Generator (v4 & v1)

Generate cryptographically random UUID v4 and timestamp-based UUID v1 identifiers in bulk with custom formatting.

4.9 / 5· 148 verified ratings
•
100% Client-Side Privacy
•
Verified 2026 Engine
Loading tool engine...
Frequently Used With:Cron Expression Generator & Schedule Builder →Lorem Ipsum Placeholder Text Generator →HTML Entity Encoder & Decoder →Markdown to HTML Editor & Previewer →
Institutional-Grade Accuracy & Client-Side Privacy Guarantee

Unlike conventional calculator sites that send your financial numbers, payload data, or code snippets across remote web servers, Affi-Chain processes all mathematical derivations, algorithms, and data parsing 100% locally within your browser sandbox. No tracking cookies, no server-side retention, and zero transmission lag.

What is a UUID (Universally Unique Identifier)?

A UUID (Universally Unique Identifier), also standardized as a GUID (Globally Unique Identifier) under RFC 4122 and the modernized RFC 9562, is a 128-bit numerical label used to uniquely identify entities across distributed computer networks without relying on a central registration authority or coordinating database cluster.

In distributed microservices, multi-tenant databases (PostgreSQL, MongoDB, CockroachDB), and modern web applications, generating sequential auto-incrementing integer IDs (1, 2, 3...) introduces severe architectural bottlenecks:

  • It requires a centralized database lock or sequence generator to avoid duplicate IDs.
  • It exposes internal business intelligence (competitors can scrape order URLs example.com/orders/5001 to deduce sales velocity).
  • It creates distributed data synchronization conflicts when merging offline mobile data or sharded database tables.

UUIDs solve this friction by generating 128-bit values with such astronomical mathematical entropy that the probability of generating a duplicate identifier is practically zero.

The Affi-Chain UUID & GUID Generator provides bulk, 100% in-browser generation of RFC-compliant UUID v4 (Cryptographic Random) and UUID v7 (Time-Ordered Database Friendly) identifiers using the hardware-accelerated Web Crypto API (crypto.randomUUID()) with zero network latency.


Anatomy & Bit Layout of a Canonical UUID

A canonical UUID consists of 32 hexadecimal digits formatted into five hyphen-separated segments:

$$\texttt{018d9f10-7b24-7489-8d1e-2c9e47f52a10}$$ $$\underbrace{\text{8 hex digits}}{\text{time-high / random}} - \underbrace{\text{4 hex}}{\text{time-mid}} - \underbrace{\text{4 hex}}{M\text{ (Version)}} - \underbrace{\text{4 hex}}{N\text{ (Variant)}} - \underbrace{\text{12 hex digits}}_{\text{node / random bits}}$$

1. The Version Nibble ($M$)

The 13th hexadecimal character ($M$) explicitly indicates the UUID version:

  • 1 = Version 1 (Timestamp & Node MAC)
  • 4 = Version 4 (Random Entropy)
  • 5 = Version 5 (SHA-1 Named Hash)
  • 7 = Version 7 (RFC 9562 Unix Epoch Timestamp + Random)

2. The Variant Nibble ($N$)

The 17th character ($N$) specifies the binary variant. For standard RFC 4122 / RFC 9562 UUIDs, the two most significant bits are set to 10_2, meaning the character $N$ must always be 8, 9, a, or b.


Comprehensive UUID Versions Matrix (RFC 4122 & RFC 9562)

VersionFoundation PrimitiveCollision ProbabilitySortable?Primary Architecture & Use Case
UUID v4122 bits of CSPRNG entropy$1 \text{ in } 2.71 \times 10^{18}$ (after $10^9$ UUIDs)NoGeneral purpose, API tokens, session IDs, request tracing
UUID v748-bit Unix epoch ms + 74 random bitsNegligible ($> 74\text{ bits}$ entropy per ms)Yes (K-Sortable)Modern standard for database primary keys (Postgres, MySQL)
UUID v160-bit Gregorian time + hardware MACLow (fails on clock rollbacks)PartiallyLegacy systems; privacy risk (exposes client MAC address)
UUID v5SHA-1 hash of namespace + string nameZero for identical inputs (Deterministic)NoIdempotent resource mapping without databases
UUID v6Reordered Gregorian time + MACLowYesLegacy bridge for v1 to achieve time-ordering

The Database B-Tree Indexing Revolution: UUID v4 vs UUID v7

For over two decades, software engineers debated whether to use auto-incrementing integers or UUID v4 for database primary keys.

The UUID v4 B-Tree Fragmentation Problem:

Because UUID v4 is 100% random, inserting rows into a relational database (PostgreSQL, MySQL InnoDB) causes random insertions across the table's clustered B-Tree index. This triggers constant index page splits, thrashing memory caches, and causing write throughput to collapse by up to 80% to 90% as database size exceeds RAM.

The UUID v7 Solution (RFC 9562):

UUID v7 encodes the current millisecond Unix timestamp into the first 48 bits, followed by 74 cryptographically secure random bits: $$\text{UUID v7 Header} = 48 \text{ bits of Unix Epoch Milliseconds}$$ Because the leading bits increase monotonically with time, UUID v7 inserts append naturally to the right-hand edge of the database B-Tree index just like auto-incrementing integers, delivering maximum write throughput while retaining distributed generation and zero collision risk.


Practical Code Implementation: Modern In-Browser Generators

1. Ultra-Fast UUID v4 (Native Web Crypto API)

In all modern web browsers and Node.js v16.7+, generating UUID v4 requires zero third-party dependencies:

// Native hardware-accelerated UUID v4 generation:
const id = crypto.randomUUID();
console.log("Generated UUID v4:", id);
// Example: "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"

2. High-Performance UUID v7 Implementation (RFC 9562)

/**
 * Generates an RFC 9562 compliant, K-sortable UUID v7.
 * @returns {string} 36-character canonical UUID v7 string.
 */
function generateUuidV7() {
  const bytes = new Uint8Array(16);
  crypto.getRandomValues(bytes);

  // 1. Current Unix Timestamp in milliseconds (48 bits)
  const timestamp = Date.now();
  const timeHex = timestamp.toString(16).padStart(12, '0');

  // Insert 48-bit timestamp into first 6 bytes
  for (let i = 0; i < 6; i++) {
    bytes[i] = parseInt(timeHex.slice(i * 2, i * 2 + 2), 16);
  }

  // 2. Set Version 7 (bits 4-7 of byte 6 set to 0111)
  bytes[6] = (bytes[6] & 0x0f) | 0x70;

  // 3. Set Variant RFC 4122 (bits 6-7 of byte 8 set to 10)
  bytes[8] = (bytes[8] & 0x3f) | 0x80;

  // 4. Format into canonical 8-4-4-4-12 hex string
  const hex = Array.from(bytes, b => b.toString(16).padStart(2, '0')).join('');
  return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`;
}

// Verification:
console.log("Generated UUID v7:", generateUuidV7());
// Example: "018f67e2-411a-7b98-8c12-38a4d7a82910"

Comparison Matrix: Modern Unique Identifier Standards

Identifier StandardBit LengthEncoded LengthCollision SafetyDatabase Index Friendly?Standard RFC
UUID v7128 bits36 chars (hex)ExceptionalYes (K-Sortable)RFC 9562
UUID v4128 bits36 chars (hex)ExceptionalNo (Random B-Tree thrashing)RFC 4122
ULID128 bits26 chars (Base32)ExceptionalYes (Monotonic sortable)Community spec
NanoIDConfigurable21 chars (URL-safe)VariableNo (Random)Community spec
Auto-Increment Integer32/64 bits1–19 charsRequires central lockYes (Sequential)SQL Standards

Critical Edge Cases & Common Pitfalls

1. The Math.random() Security Catastrophe

A fatal security vulnerability occurs when developers construct pseudo-UUIDs using Math.random() (e.g., 'xxxxxxxx-xxxx-4xxx...'.replace(/[xy]/g, ...)). In V8, Math.random() relies on the non-cryptographic Xoroshiro128+ algorithm. Attackers who observe several generated IDs can mathematically deduce internal PRNG seed states, predicting future session tokens or password reset UUIDs. Always use crypto.getRandomValues() or crypto.randomUUID().

2. Case Sensitivity Conventions

Under RFC 4122 §3, the hexadecimal characters in a UUID must be output and compared as lowercase. While parsers must accept uppercase inputs case-insensitively, systems that store UUIDs as case-sensitive strings in Redis or external APIs risk failed string lookups if capitalization fluctuates.

Frequently Asked Questions

Is UUID v4 truly unique?
Yes. UUID v4 uses 122 bits of cryptographic randomness. Collision probability is roughly 1 in 2.71 quintillion.

Explore Related Utilities