UUID Generator: Create Unique Identifiers Instantly
UUIDs (Universally Unique Identifiers) are 128-bit identifiers that are practically guaranteed to be unique across space and time. They’re used everywhere — database primary keys, API request IDs, session tokens, file names, and distributed system identifiers.
What is a UUID?
A UUID is a 128-bit number typically displayed as 32 hexadecimal characters separated by hyphens:
550e8400-e29b-41d4-a716-446655440000
| | | | |
8 4 4 4 12 characters
The format is 8-4-4-4-12 for a total of 36 characters (32 hex digits + 4 hyphens).
UUID Versions
Version 4 (Random)
The most commonly used version. Generated from random numbers using a cryptographically secure random number generator.
xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
^ ^
| └── y is 8, 9, a, or b (variant)
└── Always 4 (version)
- Pros: Simple, no dependencies, no coordination needed
- Cons: No inherent ordering, not sortable by creation time
- Use when: You need a unique ID and don’t care about ordering
Version 1 (Timestamp + MAC)
Based on the current timestamp and the machine’s MAC address.
- Pros: Sortable by time, guaranteed unique per machine
- Cons: Exposes MAC address and creation time (privacy concern)
Version 7 (Unix Timestamp, newest)
A newer standard (RFC 9562) that embeds a Unix timestamp in the first 48 bits, followed by random data.
- Pros: Time-sortable, database-friendly, privacy-safe
- Cons: Newer standard, not yet universally supported
- Use when: You need sortable IDs for database primary keys
Why Use UUIDs?
Database Primary Keys
UUIDs allow generating IDs on the client side without coordinating with the database:
INSERT INTO users (id, name) VALUES ('550e8400-e29b-41d4-a716-446655440000', 'Alice');
No auto-increment conflicts in distributed systems.
API Idempotency Keys
Include a UUID with each API request to prevent duplicate processing:
POST /api/payments
X-Idempotency-Key: 7c9e6679-7425-40de-944b-e07fc1f90ae7
Distributed Systems
When multiple services generate IDs independently, UUIDs prevent collisions without a central coordinator.
File Names
Ensure uploaded files never overwrite each other:
uploads/7c9e6679-7425-40de-944b-e07fc1f90ae7.png
UUID vs Other ID Strategies
| Strategy | Pros | Cons |
|---|---|---|
| Auto-increment | Simple, sortable, compact | Centralized, predictable, exposes count |
| UUID v4 | Distributed, unpredictable | Large (36 chars), not sortable |
| UUID v7 | Distributed, sortable | 36 characters, newer standard |
| ULID | Sortable, compact (26 chars) | Less widely supported |
| Snowflake ID | Sortable, 64-bit | Requires coordination (machine ID) |
| NanoID | Compact, customizable | Not standardized |
How to Use Our UUID Generator
- Click Generate to create a new UUID v4
- Copy the UUID with one click
- Choose a format: lowercase, uppercase, with braces, or without hyphens
- Generate in bulk — specify a count to generate multiple UUIDs at once
Format Options
| Format | Example |
|---|---|
| Lowercase (default) | 550e8400-e29b-41d4-a716-446655440000 |
| Uppercase | 550E8400-E29B-41D4-A716-446655440000 |
| With braces | {550e8400-e29b-41d4-a716-446655440000} |
| No hyphens | 550e8400e29b41d4a716446655440000 |
Bulk Generation
Need multiple UUIDs? Set the count (up to 100) and generate them all at once. Each one is cryptographically random and unique.
UUID Collision Probability
With UUID v4, the probability of generating a duplicate is astronomically low. You’d need to generate:
- 1 billion UUIDs per second
- For 86 years
- To reach a 50% probability of a single collision
In practical terms: UUID collisions don’t happen.
Frequently Asked Questions
Are UUIDs truly unique? UUID v4 uses 122 random bits, giving 5.3 × 10³⁶ possible values. While collisions are theoretically possible, the probability is negligible for any real-world application.
Should I use UUIDs as database primary keys? UUIDs work well as primary keys, especially in distributed systems. However, random UUIDs (v4) can cause index fragmentation in B-tree databases. Consider UUID v7 or ULID for better index performance.
Can someone guess a UUID? UUID v4 uses cryptographically secure random numbers. Guessing a specific UUID is computationally infeasible — there are more possible UUIDs than atoms in the observable universe.
What’s the storage size? As a string: 36 bytes. As binary (16 bytes): more efficient for databases. Most databases have a native UUID type that stores them as 16 bytes.
Try our free UUID Generator to create unique identifiers instantly.
Try Ghost Image Hub
The Chrome extension that makes managing your Ghost blog images a breeze.
Learn More