Every time you create a record in a database, spin up a new session, or issue an API token, you need an identifier that is guaranteed to be unique — even across multiple servers, databases, or distributed systems. UUIDs were designed for exactly this problem.
This guide explains what a UUID is, how the different versions work (with a focus on v4), why UUIDs are used in modern systems, and how to generate one instantly with the free UUID Generator tool.
Advertisement
What is a UUID?
A UUID (Universally Unique Identifier) — also called a GUID (Globally Unique Identifier) in Microsoft environments — is a 128-bit value formatted as 32 hexadecimal digits in five groups separated by hyphens:
550e8400-e29b-41d4-a716-446655440000
The format is always 8-4-4-4-12 hex characters. The third group encodes the version number (the first digit), and the fourth group encodes the variant. Everything else in a v4 UUID is random.
UUID versions explained
| Version | How it works | Use case |
|---|---|---|
| v1 | Timestamp + MAC address | Time-ordered IDs (leaks MAC address) |
| v3 | MD5 hash of a namespace + name | Deterministic IDs from known input |
| v4 | 122 random bits | General-purpose unique IDs (most common) |
| v5 | SHA-1 hash of a namespace + name | Deterministic IDs (more secure than v3) |
| v7 | Unix timestamp + random bits | Time-sortable IDs (modern databases) |
For most use cases, UUID v4 is the right choice. It is random, requires no shared state or clock synchronisation, and is supported natively in every major database and programming language.
How to generate a UUID online
Open the UUID Generator
Go to the free UUID Generator — no sign-up required. A UUID v4 is pre-generated when the page loads.
Set quantity for bulk generation
Need more than one? Set the quantity field to generate up to 100 UUIDs at once — useful for seeding a test database or generating a batch of API tokens.
Choose format options
Toggle hyphens on/off and uppercase/lowercase to match your target system's format. Most databases accept the standard hyphenated lowercase format.
Copy and use
Click the copy button to copy the UUID(s) to your clipboard. Paste directly into your code, database seeding script, or API request.
Common UUID use cases
Database primary keys
Globally unique across distributed databases. Safe for horizontal scaling and microservices.
API resource identifiers
REST APIs use UUIDs as resource IDs in URLs: /users/550e8400-e29b-41d4-a716-446655440000.
Session tokens
UUIDs are used as session identifiers in web applications — unpredictable and unique.
File names
Rename uploaded files to UUIDs to prevent collisions and avoid exposing user data in file names.
Message queue IDs
Kafka, RabbitMQ, and similar systems use UUIDs to uniquely identify messages.
Idempotency keys
Payment APIs (Stripe, Braintree) use UUIDs as idempotency keys to safely retry requests.
UUID vs CUID vs NanoID
UUID is not the only option for generating unique identifiers. Here is how the main alternatives compare:
| Format | Example length | URL-safe | When to use |
|---|---|---|---|
| UUID v4 | 36 chars | Yes (no hyphens version: 32 chars) | Standard choice. Maximum compatibility. |
| NanoID | 21 chars (default) | Yes | Shorter URLs, modern JavaScript apps. |
| CUID2 | 24 chars | Yes | When you need collision-safe, time-monotonic IDs. |
| ULID | 26 chars | Yes | Time-sortable UUIDs — good for database indexes. |
Frequently asked questions
What is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit label used to uniquely identify information in computer systems. It is formatted as 32 hexadecimal digits in 5 groups separated by hyphens: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. The probability of generating two identical UUIDs is astronomically small.
What is UUID v4?
UUID version 4 is randomly generated — 122 of the 128 bits are random, with 6 bits used to indicate the version and variant. It is the most commonly used UUID version because it requires no server state, network calls, or timestamps. It is simply a random unique identifier.
Are UUIDs truly unique?
In practice, yes. The probability of generating a duplicate UUID v4 is approximately 1 in 5.3 × 10^36. You would need to generate about 2.7 × 10^18 UUIDs to have even a 50% chance of a single collision — effectively impossible in any real-world system.
Can I use a UUID as a database primary key?
Yes, and it is a common practice. UUID primary keys are globally unique across distributed systems. The trade-off is that UUIDs are larger than integer keys (16 bytes vs 4 bytes) and non-sequential, which can affect index performance in large tables. UUID v7 addresses the ordering issue by being time-sortable.
What is a nil UUID?
The nil UUID is a special UUID where all 128 bits are set to zero: 00000000-0000-0000-0000-000000000000. It is used as a sentinel value or placeholder in systems where you need to represent "no UUID" or an unset identifier.
How is a UUID different from a regular random string?
A UUID has a standardised format (8-4-4-4-12 hex characters), encodes version and variant bits, and is interoperable across systems and languages. A random string has no standard format. Use UUIDs when you need guaranteed interoperability. Use NanoID or similar when you need shorter, URL-safe identifiers without the UUID standard.
Generate a UUID now
Free, instant, browser-based. Generate single or bulk UUID v4 identifiers in one click — no sign-up, nothing stored.
Open UUID Generator →