Sponsored placement
What Is a UUID?
A UUID (Universally Unique Identifier), also called GUID (Globally Unique Identifier) on Windows platforms, is a 128-bit identifier formatted as 32 hexadecimal characters split into five groups by hyphens: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. The standard form looks like 550e8400-e29b-41d4-a716-446655440000.
UUIDs are designed to be globally unique without requiring a central authority to issue them. This makes them ideal for distributed systems where multiple nodes need to generate identifiers independently without coordination. A properly generated UUID v4 has a collision probability so low that it is effectively impossible — approximately one in 5.3 undecillion (5.3 × 10^36).
UUID version 4 is the most common version for general use. It generates all bits randomly except for two small fields that identify the version and variant. UUID v1 is time-based and includes the MAC address of the generating machine, which is not suitable for privacy-sensitive use cases. UUID v7, emerging in newer systems, is also time-based but designed for sortability.
- Format: 8-4-4-4-12 hexadecimal characters separated by hyphens
- UUID v4: randomly generated, most common version for identifiers
- UUID v1: time-based with MAC address, not privacy-safe
- UUID v7: time-ordered, sortable, gaining adoption in databases
- Collision probability of v4: approximately 1 in 5.3 undecillion
Common Uses for UUIDs
UUIDs are the standard choice for primary keys in distributed systems and any database where records can be created across multiple nodes or services without a central counter. Unlike auto-incrementing integer IDs, UUIDs do not expose how many records exist and cannot be guessed sequentially.
In APIs, UUIDs serve as resource identifiers that are safe to expose in URLs and responses because they reveal no information about the data structure. User IDs, order IDs, session tokens, correlation IDs for distributed tracing, and webhook delivery IDs are all common UUID use cases.
For testing, UUIDs are useful as placeholder values in database seed scripts, fixture files, API mock responses, and unit test data where you need unique values that do not conflict with real records.
- Database primary keys — especially in distributed or multi-node systems
- API resource identifiers exposed in URLs and responses
- Session tokens and correlation IDs for request tracing
- Webhook event IDs and idempotency keys
- Test data and database seed scripts
UUID vs Auto-Increment Integer — Which to Use?
Auto-incrementing integers are simpler to read, sort naturally, and are slightly more efficient to index in most databases. They are the right choice for internal tables that never expose IDs to users or external systems. UUID v4 is better for resources exposed in APIs, records created across multiple database shards, and any case where sequential IDs would expose business information (such as order numbers that reveal how many orders exist).
UUID v7 is an increasingly popular middle ground: time-ordered UUIDs that sort naturally by creation time (like integers) while still being globally unique (like UUID v4). Several modern databases and ORMs now support UUID v7 as a preferred primary key type.
Why marketers use this tool
- Generate random UUID v4 values instantly without code
- Create batches of multiple UUIDs for test data and database seeding
- Copy all generated UUIDs in one click for immediate use
Frequently Asked Questions
What is a UUID v4?
UUID v4 is a randomly generated 128-bit identifier formatted as 32 hexadecimal characters in the pattern xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx. The 4 identifies the version, and the y field is constrained to values 8, 9, a, or b. All other bits are random, making collision effectively impossible.
Are two generated UUIDs ever the same?
In practice, no. The probability of generating two identical UUID v4 values is approximately 1 in 5.3 undecillion. You would need to generate about 2.71 quintillion UUIDs before the probability of a collision reaches 50%. For all practical purposes, treat UUID v4 values as globally unique.
What is the difference between UUID and GUID?
They are the same concept. UUID (Universally Unique Identifier) is the standard term from RFC 4122. GUID (Globally Unique Identifier) is Microsoft's term for the same format. Both use the same 128-bit, 8-4-4-4-12 hex format.
Should I use UUID or integer as a primary key?
Integers are simpler and more storage-efficient for internal tables. UUID v4 is better for distributed systems, API-exposed identifiers, and cases where sequential IDs would leak business information. UUID v7 is a good compromise — time-ordered UUIDs that sort naturally but are globally unique.
Is a UUID safe to use as a secret token?
UUID v4 has 122 bits of randomness, which gives it a keyspace of about 5.3 undecillion. This is sufficient for non-cryptographic identifiers but is weaker than a dedicated cryptographic token. For high-security tokens (password reset links, API keys, session tokens), use a cryptographically secure random generator that produces at least 128 bits of entropy from a proper CSPRNG.