UUID Generator

Generate cryptographically random UUID v4 identifiers instantly — single or bulk. All generated in your browser.

Frequently Asked Questions

A UUID (Universally Unique Identifier), also called a GUID, is a 128-bit label used to uniquely identify information across distributed systems. The standard format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx — 32 hex digits split into 5 groups by hyphens. Version 4 UUIDs are randomly generated (122 random bits), giving a collision probability so low it is considered practically impossible.

UUID version 4 is generated using a cryptographically secure random number generator. The version bits (4 in position 13) and the variant bits (8, 9, A, or B in position 17) are set deterministically; the remaining 122 bits are random. It is the most widely used UUID version for unique identifiers in databases, APIs, and file systems.

In theory yes, but the probability is astronomically small — approximately 1 in 5.3 × 10³⁶. To put it in perspective: you would need to generate 1 billion UUIDs per second for 85 years before the probability of a single collision reached 50%.

UUID v1 is time-based — it encodes the current timestamp and the MAC address of the generating machine. This makes it sortable by creation time, but it leaks the machine's identity and is not suitable where privacy matters. UUID v4 is randomly generated using 122 bits of cryptographic randomness — it is the most widely used version and is appropriate when you just need a unique opaque identifier. UUID v5 is name-based using a SHA-1 hash — given the same namespace and name, it always produces the same UUID, making it deterministic and reproducible. This is useful for generating consistent IDs from domain names, URLs, or other stable input values.

UUID v4 has 122 bits of randomness, giving 2122 (approximately 5.3 × 1036) possible values. The probability of a collision is effectively zero for any realistic use case. To reach a 50% probability of a single collision, you would need to generate roughly 2.71 × 1018 UUIDs — that's 2.71 quintillion. Even generating one million UUIDs per second, it would take over 85 years to reach that number. For practical purposes, UUID v4 can be treated as globally unique without any coordination between generating systems.

ULID (Universally Unique Lexicographically Sortable Identifier) was designed to address two limitations of UUID: sortability and readability. A ULID encodes a 48-bit millisecond timestamp in the first 10 characters and 80 bits of randomness in the remaining 16 characters, using Crockford's Base32 alphabet. This makes ULIDs sortable by creation time (important for database indexing performance) and URL-friendly (no hyphens, all uppercase, no ambiguous characters). The tradeoff is that ULIDs from the same millisecond share a common prefix and are slightly more complex to generate. UUID v7, defined in RFC 9562, brings similar time-ordered properties to the UUID standard.

UUIDs as primary keys have real tradeoffs. Advantages: globally unique without coordination (safe for distributed systems, multi-tenant databases, and data merging), and they do not expose record counts or insertion order. Disadvantages: UUID v4 is random, so inserts cause index fragmentation in B-tree indexes (InnoDB/PostgreSQL), leading to poor write performance at scale. A UUID is also 4× larger than a 4-byte integer and 2× larger than a bigint. Mitigations: use UUID v7 or ULID (time-ordered) to reduce fragmentation, or use a bigint auto-increment as the physical primary key and expose the UUID as a separate unique column for external references.

The nil UUID is a special UUID where all 128 bits are set to zero: 00000000-0000-0000-0000-000000000000. It is defined in RFC 4122 as a sentinel value — it is guaranteed never to be generated as a real identifier. It is used in code to represent "no UUID" or an unset/null UUID value, similar to how null or 0 might be used for other types. Some languages have a corresponding max UUID (ffffffff-ffff-ffff-ffff-ffffffffffff, all bits set to 1) defined in RFC 9562, used as another sentinel value.

A UUID is 128 bits (16 bytes) displayed as 32 hexadecimal characters split into 5 groups by hyphens: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12 characters). For UUID v4: the version nibble is the 13th character (always 4), and the variant bits are in the 17th character (always 8, 9, a, or b). The remaining 122 bits are random. Example: f47ac10b-58cc-4372-a567-0e02b2c3d479 — the highlighted characters show the fixed version and variant bits.

UUID generation is built into most modern languages and frameworks: JavaScript (browser/Node.js): crypto.randomUUID() (Web Crypto API, available in all modern browsers and Node 15+). PHP (Laravel): Str::uuid() or \Ramsey\Uuid\Uuid::uuid4()->toString(). Python: import uuid; str(uuid.uuid4()). Go: github.com/google/uuid package — uuid.New().String(). Java: UUID.randomUUID().toString(). C# (.NET): Guid.NewGuid().ToString(). Ruby: SecureRandom.uuid. All of these use a cryptographically secure random number generator to produce v4 UUIDs.

About This UUID Generator

This free UUID generator creates version 4 (random) UUIDs using the Web Crypto API directly in your browser. Generate one or multiple UUIDs at once — no data is sent to a server.

Version 4 UUIDs are 128-bit random identifiers with extremely low collision probability, making them suitable for database primary keys, distributed system identifiers, file names, and any scenario requiring a globally unique ID without central coordination.

When to use this tool

  • Generating unique IDs for new database records
  • Creating idempotency keys for API requests
  • Producing unique file or object storage names
  • Testing UUID-based systems with known random values

How UUID v4 Generation Works

A UUID v4 is 128 bits of data, structured according to RFC 4122, with 122 bits of cryptographic randomness.

Generate Random Bits

The browser's crypto.randomUUID() (or crypto.getRandomValues() fallback) generates 128 bits of CSPRNG data from the operating system's entropy pool.

Set Version & Variant Bits

Bits 48–51 are set to 0100 (version 4). Bits 64–65 are set to 10 (RFC 4122 variant). These 6 deterministic bits identify this as a valid v4 UUID.

Format as Hyphenated Hex

The 128 bits are hex-encoded and split into 5 groups: 8-4-4-4-12 characters. The 4th group always starts with 4 and the 5th starts with 8, 9, a, or b.

Common Use Cases

Database Primary Keys

UUIDs are ideal primary keys in distributed databases where multiple nodes insert records simultaneously. Unlike auto-increment integers, they require no coordination to guarantee uniqueness across shards.

Microservice Request IDs

Pass a UUID as a X-Request-ID or correlation ID header to trace a request across multiple services. Each service logs the same ID, making it easy to reconstruct a distributed trace.

Collision-Safe File Names

When storing user uploads, rename files to UUIDs before saving. This prevents path traversal attacks, filename collisions, and information leakage from predictable file names.

Client-Side Object Identity

In single-page apps, UUIDs are used as stable keys for UI elements (lists, forms, tabs) before they're saved to the backend — React, Vue, and Angular all benefit from stable unique keys.

Configuration & Plugin IDs

Plugins, extensions, and configuration blocks in multi-tenant SaaS apps use UUIDs to identify instances uniquely across tenants without relying on sequential integers that could be guessed.

Batch ID Generation

Use the count selector to generate up to 100 UUIDs at once for seeding test databases, pre-allocating IDs, or bulk-generating identifiers for an import script.

Related Articles

View all articles
UUID Primary Keys in PostgreSQL, MySQL, and MongoDB: Performance Differences and Implementation Patterns

UUID Primary Keys in PostgreSQL, MySQL, and MongoDB: Performance Differences and Implementation Patterns

PostgreSQL stores UUIDs as 16-byte native types with no performance penalty. MySQL's InnoDB clustered index makes random UUID v4 fragmentation far worse than in PostgreSQL. MongoDB's ObjectId is 12 bytes with an embedded timestamp. Here's how UUID primary keys actually behave in each database and the ORM patterns to use them correctly.

Jun 15, 2026
Beyond UUID: How Twitter's Snowflake IDs, ULID, CUID2, and Nano ID Work

Beyond UUID: How Twitter's Snowflake IDs, ULID, CUID2, and Nano ID Work

Twitter, Discord, and Instagram all built custom ID systems because UUID couldn't handle time-sortability, distributed generation, and 64-bit constraints simultaneously. Here's how Snowflake IDs work, what ULID and CUID2 offer, and when each alternative makes sense.

Jun 9, 2026
UUID v1, v4, v5, v7 Compared — Which Version Should You Actually Use?

UUID v1, v4, v5, v7 Compared — Which Version Should You Actually Use?

UUID v1, v3, v4, v5, and v7 all work differently and suit different use cases. Here's when to use each — including why v7 is now the recommended choice for database primary keys.

Jun 8, 2026
UUID Generator — Generate Unique Identifiers for Any Application

UUID Generator — Generate Unique Identifiers for Any Application

Learn what UUIDs are, the differences between versions 1, 4, and 7, when to use UUIDs over auto-increment integers, and how to generate them instantly with a free UUID generator.

Jun 6, 2026