UUID Generator

Generate random UUIDs (Universally Unique Identifiers) instantly. Create single or bulk UUID v4 identifiers with customizable formatting options. All UUIDs are generated locally using cryptographically secure random numbers.

About UUID v4

  • Generated using cryptographically secure random numbers
  • 122 bits of randomness = 5.3 × 10^36 possible values
  • Collision probability is effectively zero
  • All processing happens locally in your browser

What is a UUID?

A UUID (Universally Unique Identifier), also known as GUID (Globally Unique Identifier) in Microsoft systems, is a 128-bit identifier designed to be unique across all computers and time. UUIDs are represented as 32 hexadecimal digits, displayed in five groups separated by hyphens: 8-4-4-4-12.

Example: 550e8400-e29b-41d4-a716-446655440000

UUID Versions Explained

UUID v1 - Time-based

Generated from a timestamp and MAC address. Useful when you need time-ordered identifiers, but reveals information about when and where the UUID was created.

  • Time-ordered (can be sorted chronologically)
  • Contains timestamp information
  • Not ideal for security-sensitive applications

UUID v4 - Random (Most Common)

Generated entirely from random numbers (122 bits of randomness). This is the most commonly used version because it's simple, secure, and doesn't reveal any information.

  • Completely random
  • No timestamp or location information
  • Used by this generator

UUID v5 - Name-based (SHA-1)

Generated by hashing a namespace identifier and a name. The same namespace + name always produces the same UUID, making it useful for deterministic UUID generation.

UUID v7 - Time-ordered Random (Newest)

A newer standard that combines timestamp ordering with random data. Better for database performance than v4 while still being secure. Gaining adoption in modern systems.

UUID Structure

xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
│        │    │    │    │
│        │    │    │    └─ 12 random hex digits (48 bits)
│        │    │    └────── N = variant (8, 9, a, or b)
│        │    └─────────── M = version (1-5, 7)
│        └──────────────── 4 random hex digits
└───────────────────────── 8 random hex digits

Total: 32 hex digits + 4 hyphens = 36 characters

Common Use Cases

Database Primary Keys

UUIDs are often used as primary keys in databases, especially in distributed systems where multiple nodes need to generate IDs without coordination.

CREATE TABLE users (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  email VARCHAR(255) NOT NULL,
  created_at TIMESTAMP DEFAULT NOW()
);

API Resource Identifiers

Using UUIDs for API resources makes URLs unpredictable, preventing enumeration attacks:

// Predictable (bad for security)
GET /api/users/123

// Unpredictable (better)
GET /api/users/550e8400-e29b-41d4-a716-446655440000

File and Object Naming

UUIDs are useful for naming uploaded files or objects to avoid conflicts:

// Instead of: photo.jpg (could conflict)
// Use: 550e8400-e29b-41d4-a716-446655440000.jpg

UUID vs Auto-Increment

UUID Advantages

  • Can be generated anywhere without coordination
  • Unpredictable (better security)
  • Works across distributed systems
  • No central authority needed

UUID Disadvantages

  • Larger storage (16 bytes vs 4-8 bytes)
  • Slower to index than integers
  • Harder to read and debug
  • Not human-friendly for support tickets

UUID in Different Languages

// JavaScript
crypto.randomUUID();

// Python
import uuid
uuid.uuid4()

// Java
UUID.randomUUID()

// C# (.NET)
Guid.NewGuid()

// PHP
Str::uuid()  // Laravel
bin2hex(random_bytes(16))  // Manual

Collision Probability

UUID v4 has 122 random bits, giving about 5.3 × 10^36 possible values. The probability of generating two identical UUIDs is astronomically low:

  • After 1 billion UUIDs: 0.00000000000000000000002% chance of collision
  • To have 50% collision chance: need ~2.71 quintillion UUIDs
  • For practical purposes, UUIDs are unique

Frequently Asked Questions

What is a UUID?
UUID (Universally Unique Identifier) is a 128-bit identifier that's virtually guaranteed to be unique across all time and space. It's represented as a 36-character string in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. UUIDs are used as primary keys in databases, unique identifiers in APIs, and for tracking objects across distributed systems.
What's the difference between UUID v1 and v4?
UUID v1 is generated using a timestamp and MAC address, making it time-ordered but potentially revealing information about when and where it was created. UUID v4 is completely random (122 bits of randomness), making it more secure but not time-ordered. UUID v4 is more commonly used today for its simplicity and privacy.
What's the difference between UUID and GUID?
UUID (Universally Unique Identifier) and GUID (Globally Unique Identifier) are effectively the same thing. GUID is Microsoft's term for UUID, commonly used in Windows and .NET. Both follow the same format and generation algorithms.
How unique are UUIDs really?
Extremely unique. The probability of generating two identical UUID v4s is about 1 in 5.3 × 10^36. To have a 50% chance of a collision, you'd need to generate about 2.71 quintillion UUIDs. For practical purposes, you can consider UUIDs unique.
Should I use UUIDs as database primary keys?
UUIDs work well for distributed systems and when security is important (unpredictable IDs). However, they're larger than auto-incrementing integers (16 bytes vs 4-8 bytes), can be slower to index, and make debugging harder. Consider your specific needs: UUID v4 for security, UUID v1/v7 for time-ordering, or auto-increment for simplicity.
What are the different UUID versions?
Version 1: timestamp + MAC address. Version 2: DCE security (rare). Version 3: MD5 hash of namespace + name. Version 4: random (most common). Version 5: SHA-1 hash of namespace + name. Version 6/7/8: newer standards for better database performance.

Related Tools