Developer Guide

UUID Generator Guide — What Is a UUID and How to Generate One

Everything you need to know about UUIDs: what they are, the difference between v1, v4, and v5, how to generate them securely in the browser, and when to use them over other identifier schemes.

What Is a UUID?

A UUID (Universally Unique Identifier), also called a GUID (Globally Unique Identifier), is a 128-bit number formatted as 32 hexadecimal characters in the pattern xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. For example: 550e8400-e29b-41d4-a716-446655440000.

UUIDs are designed to be unique across all systems and all time without requiring a central coordinator to assign them. This makes them ideal for distributed systems, database primary keys, session tokens, file names, and any situation where multiple systems need to create unique identifiers independently.

UUID Versions Explained

UUID v1 — Time-Based

UUID v1 encodes the current timestamp (at 100-nanosecond resolution since 1582) and the MAC address of the generating machine. While guaranteed unique (given accurate clocks), v1 UUIDs expose when and where they were generated — a privacy and security concern in many applications.

UUID v4 — Randomly Generated (Most Common)

UUID v4 generates 122 bits of cryptographic randomness. The remaining 6 bits are fixed version and variant markers. With 2^122 possible values (~5.3 × 10^36), collisions are statistically impossible for any real-world use case. This is the version you should use for most applications.

UUID v5 — Name-Based (SHA-1)

UUID v5 generates a deterministic UUID from a namespace and a name using SHA-1 hashing. Given the same inputs, it always produces the same UUID — useful for creating stable identifiers for known resources without storing a mapping table.

UUID v7 — Time-Ordered Random (Emerging Standard)

The newer UUID v7 standard (RFC 9562) combines a millisecond-precision Unix timestamp prefix with random bits, making UUIDs both unique and naturally sortable by creation time — ideal for database primary keys where index fragmentation is a concern.

How to Generate UUID v4 in the Browser

Modern browsers support crypto.randomUUID() natively (Chrome 92+, Firefox 95+, Safari 15.4+). This generates a cryptographically secure UUID v4 with a single function call:

const uuid = crypto.randomUUID();
// → "550e8400-e29b-41d4-a716-446655440000"

For environments without crypto.randomUUID(), you can construct a v4 UUID manually using crypto.getRandomValues(), setting bits 12–15 of the third group to 0100 (version 4) and bits 6–7 of the fourth group to 10 (variant 1).

Need random identifiers that are not strictly UUIDs? The SHA Hash Generator can produce 256-bit or 512-bit hex identifiers, and the Base64 Encoder can encode random binary data into URL-safe strings.

UUID vs Other Identifier Schemes

IdentifierFormatSortablePrivateBest Use
UUID v432 hex charsNoYesGeneral unique IDs
UUID v732 hex charsYesYesDatabase PKs
UUID v132 hex charsYesNoLegacy systems
SHA-256 hash64 hex charsNoYesContent addressing
ULID26 chars (Base32)YesYesSortable compact IDs
Auto-incrementIntegerYesNoSimple sequential IDs

Useful Related Tools

Frequently Asked Questions

What is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit identifier formatted as 8-4-4-4-12 hexadecimal characters (e.g. 550e8400-e29b-41d4-a716-446655440000). UUIDs are designed to be unique across all space and time without requiring a central authority to assign them.
What is the difference between UUID v4 and UUID v1?
UUID v4 is randomly generated — 122 of its 128 bits are random. UUID v1 is time-based and includes the MAC address of the generating machine. v4 is preferred for most applications because v1 can reveal when and where it was created.
Are UUID v4 values truly unique?
With 2^122 possible values (~5.3 × 10^36), the probability of a collision between two randomly generated UUIDs is astronomically small — effectively zero for any practical application. You would need to generate approximately 2.7 × 10^18 UUIDs before having a 50% chance of a single collision.
Can I use a random password generator to create UUIDs?
Not directly — UUIDs have a specific format with version and variant bits set to particular values. You can use our Base64 encoder or SHA hash generator to generate random identifiers, or use crypto.randomUUID() in modern browsers and Node.js for proper UUID v4 generation.