← Back to FreeTextUtils  · 

📅 Updated: June 1, 2026 | ⏱️ Reading time: 10 minutes | ✍️ By FreeTextUtils Team

What Is a UUID?

A UUID (Universally Unique Identifier) is a 128-bit identifier standardized by the Open Software Foundation (OSF) as part of the Distributed Computing Environment. UUIDs are designed to be unique across both space and time, without requiring a central registration authority. The term GUID (Globally Unique Identifier) is often used interchangeably, particularly in Microsoft ecosystems.

The key property of a UUID is that any UUID generated today will be unique from all other UUIDs generated anywhere in the world, now and in the future. This makes UUIDs ideal for distributed systems where multiple nodes need to generate identifiers independently without coordinating with each other.

A typical UUID v4 looks like this: f47ac10b-58cc-4372-a567-0e02b2c3d479. It consists of 32 hexadecimal characters arranged in five groups separated by hyphens, following the 8-4-4-4-12 pattern.

UUID Versions Explained

The UUID specification defines several versions, each using different methods to generate the identifier:

UUID v1: Time-Based

UUID v1 uses the current timestamp (in 100-nanosecond intervals since October 15, 1582) combined with the generating node's MAC address. This guarantees uniqueness across time and space. However, the MAC address inclusion raises privacy concerns, and the time-based nature means UUIDs are sortable by creation time.

UUID v3: Name-Based (MD5)

UUID v3 generates a UUID from a namespace identifier and a name string using MD5 hashing. The same inputs always produce the same UUID. This is useful for generating deterministic identifiers from names without coordinating with a central authority.

UUID v4: Random

UUID v4 generates UUIDs using random or pseudo-random numbers. Of the 128 bits, 6 bits are used for version and variant indicators, leaving 122 bits for random data. This provides approximately 5.3 x 10^36 possible UUIDs, making the probability of collision astronomically low. Version 4 is the most widely used UUID type and is what our tool generates.

UUID v5: Name-Based (SHA-1)

Similar to v3 but uses SHA-1 hashing instead of MD5. UUID v5 is preferred over v3 in modern applications because SHA-1 is more secure than MD5. Like v3, it is deterministic based on namespace and name inputs.

UUID v6, v7, v8: New Formats

These newer versions (standardized in 2023) offer improved properties. UUID v6 is a reordered time-based UUID. UUID v7 uses Unix timestamps with random data, making it ideal for database indexes and modern applications. UUID v8 is a custom format for experimental use.

UUID Format and Structure

A UUID is represented as a 36-character string (32 hexadecimal digits + 4 hyphens) in the format xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx, where:

  • M indicates the UUID version (1, 2, 3, 4, or 5)
  • N indicates the variant (one of 8, 9, a, or b)
  • The remaining x positions are random or deterministic depending on the version

Example UUID v4 breakdown:

f47ac10b-58cc-472-a567-0e02b2c3d479

The digit 4 indicates version 4 (random). The digit 5 indicates the variant (RFC 4122). The remaining digits are randomly generated.

Common Use Cases for UUIDs

Database Primary Keys

Using UUIDs as primary keys in database tables offers several advantages over auto-incrementing integers. UUIDs can be generated on the application side before insertion, enabling batch inserts and offline operation. They also prevent enumeration attacks — users cannot guess other users' IDs by incrementing numbers. UUIDs are essential in distributed databases where different nodes must generate identifiers without conflict.

API Resource Identifiers

RESTful APIs commonly use UUIDs as resource identifiers. A URL like /api/users/f47ac10b-58cc-4372-a567-0e02b2c3d479 is unambiguous, unguessable, and does not leak information about the total number of resources.

Distributed Systems

In microservices architectures, event sourcing systems, and message queues, UUIDs allow different services to generate unique identifiers for events, commands, and entities without needing a central ID generation service.

Session and Transaction IDs

UUIDs make excellent session identifiers, transaction tracking codes, and correlation IDs for logging. Their randomness and uniqueness ensure that sessions cannot be forged, and that log entries from different parts of a distributed system can be correlated.

File and Asset Naming

When users upload files to a system, renaming them with UUIDs prevents naming conflicts and path traversal attacks. A file named report.pdf becomes a1b2c3d4-e5f6-7890-abcd-ef1234567890.pdf — unique and safe.

Real-World Examples

Example 1: E-Commerce Order Tracking

Scenario: An e-commerce platform processes orders from multiple web servers behind a load balancer. Each server needs to generate unique order IDs.

Challenge: Using auto-increment IDs would require a shared database sequence, creating a bottleneck and single point of failure.

Solution: Each server generates UUID v4 order IDs locally. Orders across all servers are guaranteed unique. Customers receive order IDs like ORD-f47ac10b-58cc-4372-a567. No database coordination is needed, and the system scales horizontally without any ID-related issues.

Example 2: Multi-Tenant SaaS Application

Scenario: A SaaS platform stores data from thousands of tenants in a shared database. Each tenant's records must be isolated and identifiable.

Challenge: Sequential IDs across tenants could cause collisions or data leakage between tenants.

Solution: Every record across all tables uses UUID v4 as the primary key. Tenant isolation is enforced through tenant IDs (also UUIDs). New tenants are provisioned instantly by generating UUIDs on the application side without waiting for database sequences.

Example 3: Microservices Event Bus

Scenario: A company's microservices architecture uses an event bus to communicate. Each event must be uniquely identifiable for tracking and debugging.

Challenge: Events can be emitted by any of 50+ services, sometimes thousands per second. IDs must never collide.

Solution: Every event includes a UUID v4 as its event ID. The operations team can trace any event's lifecycle across services using this ID. When debugging issues, they search logs by event UUID to see exactly what happened across the entire distributed system.

UUID vs Other Identifier Types

Feature UUID v4 Auto-Increment ID ULID Snowflake
Length128 bits (36 chars)Variable (4-8 bytes)128 bits (26 chars)64 bits (19 chars)
SortableNoYesYesYes
DistributedExcellentPoorExcellentGood
Human-readableLowHighMediumHigh
Collision riskNegligibleZero (centralized)NegligibleNegligible
Database index perfFairExcellentGoodExcellent

Frequently Asked Questions

Q: Can two UUIDs ever be the same?

A: The probability of a UUID v4 collision is extremely low — about 1 in 5.3 octillion (5.3 x 10^36). You would need to generate over 1 billion UUIDs per second for 100 years to have a 50% chance of a single collision. For all practical purposes, UUID v4 collisions do not occur.

Q: Is UUID v4 truly random?

A: UUID v4 generated by our tool uses crypto.getRandomValues(), which is cryptographically secure. The random bits come from the operating system's entropy source, not a pseudo-random number generator.

Q: Can I use UUIDs as database primary keys?

A: Yes, but be aware of performance implications. UUIDs are larger than integers (16 bytes vs 4-8 bytes) and their randomness can cause index fragmentation in B-tree indexes. UUID v7 addresses this by being time-sortable. For small to medium databases, the benefits usually outweigh the costs.

Q: What is the difference between UUID and GUID?

A: Technically, GUID is Microsoft's implementation of the UUID standard. In practice, the terms are used interchangeably. All GUIDs are UUIDs (specifically, they follow the UUID RFC 4122 specification).

Q: Should I use dashes in UUIDs?

A: The standard string representation includes dashes (e.g., f47ac10b-58cc-4372-a567-0e02b2c3d479). Some systems store UUIDs without dashes (f47ac10b58cc4372a5670e02b2c3d479) to save space. Both are valid, but with dashes is more readable.

Ready to Generate UUIDs?

Use our free online UUID generator to create unique identifiers instantly:

  • Generate UUID v4 with cryptographically secure randomness
  • Copy to clipboard with one click
  • 100% browser-based processing
  • No limits on generation count
  • Works on any device
Go to UUID Generator Tool