UUID Generator

Generators

Generate UUIDs v4 and v7 instantly — bulk or single

0 UUIDs · V4
UUID v4Random

122 random bits. No ordering or timestamp. Best for general-purpose unique identifiers.

UUID v7Time-sorted

48-bit Unix timestamp + random. Sortable by creation time. Ideal for database primary keys.

What is a UUID?

A UUID (Universally Unique Identifier) is a 128-bit label used to uniquely identify information in computer systems. Unlike sequential integer IDs, UUIDs can be generated independently on any machine without coordination — and the probability of duplicates is negligible.

UUIDs are represented as 32 hexadecimal digits, displayed in five groups separated by hyphens in the form xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx, where M indicates the version and N indicates the variant.

UUID Versions Explained

v1Timestamp + MAC

Based on timestamp and MAC address. Leaks hardware identity. Largely superseded by v7.

v4Random

122 random bits. Most widely used version. No ordering, no information leakage.

v5Name-based (SHA-1)

Deterministic — same input always produces the same UUID. Useful for generating IDs from known data.

v7Time-sorted

48-bit ms timestamp + random. Sortable, index-friendly. Recommended for new projects.

NilSpecial

All zeros: 00000000-0000-0000-0000-000000000000. Used as a sentinel/default value.

MaxSpecial

All ones: ffffffff-ffff-ffff-ffff-ffffffffffff. Used as an upper bound sentinel.

UUID v4 vs v7: When to Use Which

v4 (Random)v7 (Time-sorted)
SortableNoYes — by creation time
DB index performancePoor (random inserts)Excellent (sequential)
Timestamp embeddedNoYes (ms precision)
Random bits12274
Best forTokens, session IDs, correlation IDsPrimary keys, event IDs, logs

UUIDs as Database Primary Keys

Using UUIDs as primary keys allows generating IDs client-side without a database round-trip, simplifies data merging across systems, and prevents ID enumeration attacks. However, random v4 UUIDs cause poor B-tree index performance because inserts are scattered randomly across the index pages.

UUID v7 solves this. Because the first 48 bits are a millisecond timestamp, new UUIDs are always greater than previous ones. This means they insert at the end of the index — just like auto-increment integers — while retaining all the benefits of distributed ID generation.

For PostgreSQL, store UUIDs as the native uuid type (16 bytes) rather than varchar(36) (37 bytes). For MySQL 8+, use BINARY(16) with UUID_TO_BIN() for optimal storage.

Frequently Asked Questions

What is a UUID?+

A UUID (Universally Unique Identifier) is a 128-bit identifier standardized by RFC 9562 (formerly RFC 4122). UUIDs are designed to be unique across space and time without requiring a central authority. They are represented as 32 hexadecimal digits grouped in a 8-4-4-4-12 pattern separated by hyphens, such as 550e8400-e29b-41d4-a716-446655440000.

What is the difference between UUID v4 and v7?+

UUID v4 generates 122 random bits, making collisions astronomically unlikely but providing no ordering. UUID v7, introduced in RFC 9562, embeds a 48-bit Unix millisecond timestamp in the first 48 bits followed by random data. This means v7 UUIDs are time-sortable — they naturally sort by creation time, which dramatically improves database index performance when used as primary keys.

Can UUIDs collide?+

While theoretically possible, a UUID v4 collision is extraordinarily unlikely. With 122 random bits, you would need to generate approximately 2.71 × 10^18 UUIDs to have a 50% probability of a single collision. For practical purposes, UUID collisions are considered impossible in real-world applications.

Should I use UUID v4 or v7 for database primary keys?+

UUID v7 is strongly recommended for database primary keys. Because v7 UUIDs are time-sorted, they insert into B-tree indexes sequentially, avoiding random page splits that fragment the index. This can improve write performance by 2-10x compared to random v4 UUIDs in databases like PostgreSQL, MySQL, and MongoDB.

What is the difference between UUID and GUID?+

UUID and GUID (Globally Unique Identifier) are essentially the same thing. GUID is the term used by Microsoft (used in Windows, .NET, SQL Server), while UUID is the standard term used by the IETF RFC and most other platforms. They use the same format and are interchangeable.

Built With

This generator uses the Web Crypto API for cryptographically secure random bytes — no external UUID libraries.