Tools
Online UUID Generator
Generate cryptographically secure UUID v4 values right in your browser. Options for hyphenated or plain format, uppercase or lowercase, and bulk generation.
Unique identifiers without central coordination
In distributed systems, generating unique IDs without a central server handing out sequences is a classic challenge. UUID v4 solves it elegantly: any client, anywhere in the world, can generate an identifier with a practical guarantee of global uniqueness, without querying any external service.
This is especially valuable in modern architectures with microservices, offline-first applications, data sync between devices and any scenario where multiple systems need to create records independently before syncing them.
The 128-bit structure of a UUID
A UUID is written as 32 hexadecimal digits in five groups separated by hyphens: 8-4-4-4-12 characters (e.g., 550e8400-e29b-41d4-a716-446655440000). It is 128 bits in total; for version 4, four fixed bits indicate the version (0100) and two indicate the variant (10). The remaining 122 bits are random.
The hyphenated format is the most common for readability, but the form without hyphens (32 hex characters) is more compact for storage and URLs. Both represent exactly the same value: they are just different ways of displaying the same 128 bits.
UUID v7: the sortable successor for databases
UUID v4 has a drawback in databases with B-tree indexes: since it is completely random, constant inserts fragment the index and degrade performance over time. UUID v7 (RFC 9562, approved in 2024) fixes this by embedding a 48-bit Unix timestamp in the first bits of the UUID, making it chronologically sortable.
With UUID v7, consecutive inserts go to the end of the index, just like auto-increment, while keeping generation decentralized and not exposing counters. For new projects that need high scale, UUID v7 is generally the best choice. For immediate compatibility with existing libraries, UUID v4 remains the default.
UUIDs in distributed systems and microservices
In architectures with multiple independent services, each with its own database, UUIDs let every service create records with globally unique IDs without a centralized sequence service that would be a single point of failure. When merging data from different sources, there is no risk of ID collisions.
On the frontend, UUIDs let you create a record's ID before saving it to the server. This is useful for optimistic updates (showing the change in the UI before the server confirms it), building offline-first systems with later sync, and referencing entities before any of them is persisted.
Security: can a UUID be used as an access token?
UUID v4 has 122 bits of entropy, which makes it suitable as a token for email confirmation links, password reset tokens and temporary access links. However, for long-lived session tokens or high-security API tokens, prefer 256 bits of entropy (32 random bytes in hex or Base64).
One important point: store hashes of tokens, never plaintext tokens. If the database is compromised, plaintext tokens grant immediate access. Hashes made with bcrypt or SHA-256 make the tokens useless even with database access.
Frequently asked questions
What is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit identifier written as 32 hexadecimal digits separated by hyphens in the 8-4-4-4-12 format. It is designed to be unique without a central server coordinating generation. The probability of two UUID v4 values colliding is astronomically small, lower than the chance of being hit by a meteorite.
What is the difference between UUID v4 and other versions?
UUID v1 is based on the current timestamp and the machine's MAC address: sequential but with privacy implications. UUID v3 and v5 are deterministic, generated from a namespace and a name using MD5 or SHA-1. UUID v4 is completely random and the most widely used for unique record identifiers. UUID v7 is recent and combines a timestamp with randomness, making it chronologically sortable, which is ideal for database indexes.
What is the probability of two UUID v4 values colliding?
With 122 bits of effective randomness (6 bits are fixed to identify the version and variant), a UUID v4 has 2^122 possible combinations, roughly 5.3 × 10^36. To reach a 50% chance of a collision, you would need to generate about 2.71 × 10^18 UUIDs. In practice, for any application, a collision is considered impossible.
UUID or auto-increment: when to use each?
Auto-increment is compact (4 or 8 bytes), sortable, easy to debug and performs very well in B-tree indexes. UUID (16 bytes) is better when data is generated in multiple systems without central coordination, you do not want to expose the number of records to the client, you need to generate IDs on the frontend before saving, or you are merging data from multiple databases. UUID v7 reduces the performance drawback because it is sortable.
How do I use UUIDs in a database?
PostgreSQL has a native UUID type with optimized indexing. MySQL stores it better as BINARY(16) than as CHAR(36). In SQL Server, the UNIQUEIDENTIFIER type stores UUIDs natively. Avoid storing them as VARCHAR(36): it takes more space and comparisons are slower. For UUID v4 in MySQL, consider UUID v7 or ULID, which are sortable and cause less index fragmentation.
Can a UUID be used in URLs?
Yes. UUIDs in URLs (like /orders/550e8400-e29b-41d4-a716-446655440000) are practical and safe: they reveal nothing about other records and are hard to guess, though being opaque is no substitute for proper authorization. The form without hyphens (32 chars) is more compact for URLs. For even shorter URLs, consider encoding the UUID in Base62 or using ULIDs.

