UUID Generator: Understanding Universally Unique Identifiers

A deep dive into UUIDs β€” the 128-bit identifiers that power databases, distributed systems, and virtually every modern application.

Developer Tools πŸ“… April 13, 2026 ⏱ 10 min read
β†’ Try Our Free UUID Generator

What Is a UUID?

A UUID (Universally Unique Identifier) is a 128-bit identifier that is practically guaranteed to be unique across space and time. First standardized in RFC 4122 (2005) and significantly updated in RFC 9562 (2024), UUIDs provide a way to generate identifiers without any central coordination β€” making them ideal for distributed systems, microservices, and any application where multiple nodes need to create unique IDs independently.

UUIDs are everywhere in modern software. Every database record in a DynamoDB table has a UUID. Every Docker container gets a UUID. Your operating system uses UUIDs to identify disk partitions. Web browsers assign UUIDs to cookies and sessions. Mobile apps use UUIDs for device identification. If you've interacted with any software in the past decade, you've almost certainly used dozens of UUIDs without realizing it.

The term GUID (Globally Unique Identifier) is often used interchangeably with UUID, particularly in Microsoft ecosystems. They refer to the same concept and use the same format. "UUID" is the standard terminology; "GUID" is a Microsoft convention.

UUID Format and Structure

A UUID is represented as a 36-character string consisting of 32 hexadecimal digits and 4 hyphens, organized in five groups:

xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

The five groups contain 8, 4, 4, 4, and 12 characters respectively. In binary, a UUID is 128 bits divided as follows:

time_low (32 bits)
time_mid (16 bits)
time_hi_and_version (16 bits)
clock_seq_hi_and_reserved (8 bits)
clock_seq_low (8 bits)
node (48 bits)

The version field (bits 4-7 of the 7th octet) indicates the UUID variant and version. For example, in UUID v4, this field is set to 4. The variant field (bits 6-7 of the 9th octet) is typically set to 10xx (binary), indicating RFC 4122 UUIDs.

Here's a real UUID v4 example:

f47ac10b-58cc-4372-a567-0e02b2c3d479

The "4" in the third group indicates version 4. The "a", "b", "8", or "9" that begins the fourth group indicates the RFC 4122 variant. These metadata bits are part of what makes UUIDs self-describing β€” you can always identify the version from the string alone.

UUID Versions Explained (v1 through v8)

UUIDs come in several versions, each with different generation strategies and trade-offs. Understanding the differences is crucial for choosing the right one for your use case.

UUID v1: Time-Based

UUID v1 combines a 60-bit timestamp (representing 100-nanosecond intervals since October 15, 1582), a 14-bit clock sequence (to handle clocks running backwards or systems generating multiple UUIDs in the same interval), and a 48-bit node identifier (typically the MAC address of the generating machine).

Advantage: Time-ordered, making it naturally sortable and database-friendly.
Disadvantage: Exposes the MAC address and generation timestamp, raising privacy concerns. Also susceptible to collisions if the clock sequence isn't managed correctly across multiple machines.

UUID v3: Name-Based (MD5)

UUID v3 is generated by hashing a namespace UUID and a name (string) with MD5. The same namespace and name always produce the same UUID. This is useful for deterministic ID generation but inherits MD5's collision vulnerabilities.

UUID v4: Random

UUID v4 is generated entirely from random numbers (a CSPRNG). All 122 random bits (6 bits are reserved for version and variant) are chosen independently, giving 2122 possible values. This is the most widely used UUID version and what most people mean when they say "generate a UUID."

Advantage: No coordination needed, no information leakage, excellent uniqueness guarantees.
Disadvantage: Completely random β€” not sortable by creation time, which can cause performance issues as database primary keys due to index fragmentation.

UUID v5: Name-Based (SHA-1)

Similar to v3 but uses SHA-1 instead of MD5. More collision-resistant than v3, but SHA-1 is also considered deprecated for security applications. Still useful for deterministic ID generation where you need reproducible identifiers from a namespace and name.

UUID v6: Reordered Time-Based

UUID v6 reorders the timestamp fields from v1 so that the most significant bits of the timestamp come first in the string representation. This makes v6 UUIDs lexicographically sortable by creation time while maintaining compatibility with v1 UUID layouts.

UUID v7: Time-Ordered Random

UUID v7 is the newest and most recommended version (RFC 9562, 2024). It combines a Unix timestamp in milliseconds (48 bits) with random bits (74 bits). The timestamp occupies the most significant bits, making v7 UUIDs naturally time-sortable. The random component ensures uniqueness even when multiple UUIDs are generated in the same millisecond.

0192a8c8-7b43-7a3b-bf4c-9e1a2d3c4e5f
 └── timestamp β”€β”€β”˜β””β”€randβ”˜β””β”€β”€β”€β”€ random bits β”€β”€β”€β”€β”˜

Advantage: Time-ordered for database performance, random for uniqueness, no privacy leakage, and follows the latest standard. This is the best all-around choice for 2026 and beyond.

UUID v8: Custom

UUID v8 is a reserved version for vendor-specific implementations. It provides a flexible format that organizations can customize for their specific needs, though it's less widely supported than the other versions.

β†’ Generate UUIDs (v4 and v7) Now

Why UUID v7 Is the Future

The adoption of UUID v7 represents a significant evolution in identifier design. For years, the developer community debated whether to use random UUIDs (v4) or auto-incrementing integers for primary keys. UUID v7 effectively resolves this debate by combining the best of both approaches.

The timestamp prefix means that records are naturally inserted in chronological order in B-tree indexes (used by PostgreSQL, MySQL, and most databases). This eliminates the index fragmentation problem that plagues random UUIDs, where new records are scattered throughout the index rather than appended at the end. Fragmentation causes increased I/O, larger index sizes, and degraded query performance.

Major databases and ORMs are adding native v7 support. PostgreSQL 17 includes UUID v7 generation functions. Prisma, Hibernate, and other ORMs now support v7 as a first-class ID strategy. The ecosystem is converging on v7 as the default recommendation for new projects.

How to Generate UUIDs

Generating UUIDs is straightforward across virtually every platform:

Online Generator

RiseTop's UUID generator lets you generate single or bulk UUIDs in v4 or v7 format, with options for uppercase/lowercase and different formatting. Everything runs in your browser.

Command Line

On Linux and macOS:

uuidgen          # Generates a random UUID (typically v4)
uuidgen -v 7      # Generates a UUID v7 (if supported)

On Windows (PowerShell):

[guid]::NewGuid().ToString()
# Output: f47ac10b-58cc-4372-a567-0e02b2c3d479

Programming Languages

In Python (using the uuid module):

import uuid
uuid.uuid4()   # Random UUID v4
uuid.uuid7()   # Time-ordered UUID v7 (Python 3.13+)

In JavaScript (browser and Node.js):

crypto.randomUUID()  // Generates UUID v4
// For UUID v7, use the uuid npm package:
import { v7 as uuidv7 } from 'uuid';
uuidv7();

UUIDs as Database Primary Keys

Using UUIDs as primary keys has become increasingly common, especially in distributed and microservice architectures. Here's what you need to know:

Benefits

Considerations

The recommendation for 2026: use UUID v7 for primary keys in new projects. It provides the uniqueness of UUIDs with the index-friendly ordering of sequential IDs.

Best Practices for UUID Usage

UUIDs vs Auto-Increment IDs

The choice between UUIDs and auto-incrementing integers depends on your architecture and requirements:

Use auto-increment when: Your application runs on a single database, you need maximum storage and performance efficiency, and you don't need to generate IDs outside the database.

Use UUIDs when: You have a distributed system with multiple databases, you need to generate IDs before database insertion (e.g., in client-side applications), or you need to merge data from different sources without conflicts.

In practice, many large-scale applications use a hybrid approach: UUIDs for external-facing identifiers and internal references, with auto-increment or Snowflake-style IDs for internal database operations where performance is critical.

Frequently Asked Questions

What is the difference between UUID and GUID?

UUID and GUID refer to the same concept. UUID (Universally Unique Identifier) is the formal standard term from RFC 4122, while GUID (Globally Unique Identifier) is Microsoft's terminology. They are functionally identical and use the same format.

Can UUIDs collide?

Theoretically yes, but practically no. UUID v4 has 2^122 possible values. Even generating a billion UUIDs per second for a billion years, the probability of a collision is approximately 1 in 10^18. For UUID v7, time-based ordering makes collisions even less likely in practice.

Which UUID version should I use?

For new projects in 2026, UUID v7 is the best choice β€” it's time-ordered for better database indexing performance and follows the latest RFC 9562 standard. UUID v4 remains widely used and is fine for non-indexing purposes. Avoid v1 for privacy concerns.

Are UUIDs good primary keys for databases?

UUIDs make excellent primary keys in distributed systems because they can be generated independently without coordination. UUID v7 is ideal because its time-based ordering aligns with B-tree index structures, avoiding index fragmentation that random UUIDs like v4 can cause.

How do I generate a UUID?

You can generate UUIDs using online tools like RiseTop's UUID generator, command-line tools (uuidgen on Linux/macOS, PowerShell's [guid]::NewGuid()), or programming language libraries (uuid module in Python, crypto.randomUUID() in JavaScript).

Related Articles