UUID / GUID Generator

Generate cryptographically secure random UUIDs and GUIDs (RFC 9562 / RFC 4122) in bulk in your browser, with full reference guides for UUIDv4 and time-ordered UUIDv7.

The Architecture of Universally Unique Identifiers (RFC 9562)

A UUID (Universally Unique Identifier)—also standardized as a GUID (Globally Unique Identifier) under ITU-T Recommendation X.667—is a 128-bit value designed to provide unique identity across distributed computer systems without requiring a central registration authority or synchronization coordinator.

Originally formalized in RFC 4122 (2005) and comprehensively overhauled in RFC 9562 (May 2024), UUIDs are represented canonically as a 36-character string comprising 32 hexadecimal digits separated by hyphens in an 8-4-4-4-12 structure:

xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
                |    |
                |    +-- Variant (Bits 64-65: 10xx denotes RFC 9562 / RFC 4122)
                +------- Version (Bits 48-51: e.g., 0100 for v4, 0111 for v7)

The Complete Taxonomy of UUID Versions (v1 through v7)

RFC 9562 standardizes multiple UUID variants, each engineered for distinct architectural tradeoffs:

VersionGeneration StrategyPrimary StrengthsVulnerabilities & Limitations
UUID v1100ns Gregorian timestamp + Clock sequence + MAC addressGuaranteed unique per physical hardware nodeSevere privacy leak (exposes physical host MAC address and timestamp)
UUID v3 & v5Deterministic hash of namespace + name (MD5 for v3, SHA-1 for v5)Deterministic idempotency (identical inputs produce identical UUIDs)Non-random, requires managing namespace UUIDs; MD5/SHA-1 cryptographically obsolete
UUID v4122 bits of pure cryptographic randomnessComplete unpredictability; perfect for auth tokens and API keysCompletely random ordering degrades database B-Tree index performance
UUID v7 (Modern)48-bit Unix timestamp (ms) + 74 bits of cryptographic entropyMonotonically sortable, sequential B-tree clustering, zero hardware leaksSlight timestamp disclosure (exposes creation time to the nearest millisecond)

The Mathematical Physics of UUID v4 Collisions

A UUID v4 contains exactly 122 bits of true entropy (128 bits minus 4 bits for version 0100 and 2 bits for variant 10). The total search space encompasses:

Total Possibilities = 2122 ≈ 5.3169 × 1036

The Birthday Paradox & Collision Probability

According to the Birthday Problem, the probabilityP of experiencing at least one accidental hash collision when generatingk independent UUIDs is approximated by:

P(k) ≈ 1 - e-k2 / (2 × 2122)

To put this number into perspective:

  • If an application generates 1 billion UUIDs per second for 100 consecutive years, the probability of generating a single collision remains under 0.000000000000001%.
  • To have a one-in-a-billion (10-9) chance of a collision, you would need to generate over 103 trillion UUIDs.

For all practical purposes across modern computing architectures, UUID v4 collisions do not occur when generated using high-quality CSPRNG sources.

UUID v7 & The Database B-Tree Index Fragmentation Problem

While UUID v4 is exceptional for security tokens, using random v4 UUIDs as primary keys in relational databases (PostgreSQL, MySQL/InnoDB, SQLite) creates a well-documented performance disaster:

1. The Random Insert Index Trap

Relational databases store primary keys in ordered B+ Tree index pages (typically 8KB or 16KB blocks in memory). When inserting auto-incrementing integers (like BIGSERIAL), every new record is appended cleanly to the far right leaf of the B-Tree.

Because UUID v4 keys are completely random, each new INSERT lands on a completely random page in the tree. When a target page is already full, the database engine must execute an expensive Page Split: allocating a new disk page, copying half the rows over, and updating parent index pointers. On tables with millions of rows:

  • B-Tree index pages become fragmented and only 50%–70% full, doubling disk footprint.
  • The database's buffer cache (RAM) is thrashed because every query requires reading random pages from physical disk, dropping throughput by up to 90%.
  • Write-Ahead Log (WAL) volume explodes due to frequent full-page image flushes.

2. How UUID v7 Fixes Database Indexing

Standardized in RFC 9562, UUID v7 places a 48-bit millisecond Unix epoch timestamp in the most significant bits:

/* UUID v7 Bit Allocation */
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           unix_ts_ms                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          unix_ts_ms           |  ver  |       rand_a          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|var|                        rand_b                             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            rand_b                             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Because v7 UUIDs are naturally monotonically increasing over time, newly inserted records append to the end of the index without splitting older pages—restoring auto-increment insert speeds while preserving global uniqueness across microservices!

Monotonicity & Sub-Millisecond Ordering in UUID v7

What Happens When Multiple UUIDs Are Created in the Same Millisecond?

In high-throughput microservices processing tens of thousands of requests per second, thousands of UUIDs may be requested within the exact same millisecond. RFC 9562 addresses this via sub-millisecond monotonicity:

  • Fixed-Bit Counter: The 12-bit rand_a block immediately following the timestamp is treated as an incrementing counter. Each subsequent UUID generated within the identical millisecond increments this counter, guaranteeing strict sortability.
  • Clock Skew Resilience: If an NTP synchronization adjustment shifts the system clock backwards by a few milliseconds, compliant v7 generators freeze the timestamp and continue incrementing the sequence counter until physical time catches up, preventing sequence inversions in database indexes.

Database Storage Optimization: Binary(16) vs. VARCHAR(36)

How you store UUIDs in your database dramatically impacts RAM and disk consumption:

  • PostgreSQL: Features a native uuid data type that automatically compresses the 36-character hyphenated string into 16 bytes of compact binary storage.
  • MySQL / MariaDB: Never store UUIDs as VARCHAR(36)! Storing strings wastes 36 bytes plus length prefixes per row, inflating index size. Instead, store keys as BINARY(16) and convert them using MySQL's native functions:
    -- Storing as 16-byte binary
    INSERT INTO users (id, name) VALUES (UUID_TO_BIN('018e69d2-7c34-7123-8abc-123456789abc', 1), 'Alice');

Production Code Recipes: TypeScript, Go, Python & Rust

Generating UUIDs in modern software stacks:

TypeScript / Modern Web

// Native Web Crypto API (UUID v4)
const id = crypto.randomUUID();

Go (google/uuid)

import "github.com/google/uuid"

// Generate UUID v7 (RFC 9562)
id, err := uuid.NewV7()

Python (uuid & uuid6 packages)

import uuid
# Standard v4
v4_id = uuid.uuid4()

Alternative Identifier Formats: ULID, NanoID & Snowflake

FormatLength & EncodingTime-Sortable?Key Differentiator
UUID v7 (RFC 9562)36 chars (Hexadecimal + Hyphens)Yes (millisecond)Universal native database support (PostgreSQL uuid type, SQLite, Java, Go)
ULID26 chars (Crockford's Base32)Yes (millisecond)More compact representation than UUID string; eliminates visually confusing characters (I, L, O, U)
NanoID21 chars (URL-safe A-Z, a-z, 0-9, _)No (pure random)Ultra-compact URL-friendly identifiers with configurable alphabet pools
Twitter Snowflake64-bit integer (19 digits)Yes (millisecond)Fits in a 64-bit integer (`BIGINT`); requires centralized worker node coordination

Practical Real-World Use Cases

  • Seed local database records: Generate valid UUIDs for primary keys and foreign keys when writing SQL seed scripts or test migrations.
  • Populate mock API payloads: Assign realistic UUID identifiers to mock JSON objects during frontend development.
  • Build clean demo datasets: Generate batches of unique identifiers for demo environments without resorting to sequential placeholders like 123 or test-1.
  • Test idempotency keys: Generate fresh UUIDs to pass in Idempotency-Key headers when testing payment or order-creation endpoints.
  • Construct sample event messages: Assign unique message and correlation IDs to test payloads for message queues and webhook consumers.

Zero Server Upload Guarantee

100% Client-side cryptographic generation. Tracking or logging generated UUIDs defeats their purpose and introduces serious security hazards if keys are used as session tokens or private endpoints.

OmniTools executes all random sampling and bitmasking operations directly inside your local browser sandbox via native Web Crypto APIs (crypto.randomUUID() and crypto.getRandomValues()). Zero identifiers are ever transmitted across the network or stored on external servers.

Frequently Asked Questions

What is the difference between a UUID and a GUID, and between UUIDv4 and UUIDv7?

UUID (Universally Unique Identifier, RFC 9562) and GUID (Globally Unique Identifier, Microsoft convention) share the same 128-bit format (e.g., 550e8400-e29b-41d4-a716-446655440000). UUIDv4 uses 122 cryptographically random bits, while UUIDv7 embeds a 48-bit Unix millisecond timestamp prefix followed by random bits so database primary keys sort chronologically and avoid B-Tree index fragmentation.

Are the generated UUIDs and GUIDs cryptographically secure?

Yes. All UUIDs are generated locally in your browser using the Web Crypto API (crypto.getRandomValues / crypto.randomUUID) with zero server calls, ensuring high entropy and zero collision risk.