Every distributed system eventually needs a way to create unique identifiers without coordinating with a central authority. UUIDs were designed exactly for this: generate an ID anywhere, on any machine, at any time, and the chances of collision are so astronomically small they can be treated as impossible.
What Is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit identifier standardized by RFC 4122. It is represented as 32 hexadecimal digits displayed in five groups separated by hyphens, in the format xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx — for example, 550e8400-e29b-41d4-a716-446655440000. The "M" digit encodes the version and the "N" digit encodes the variant. UUIDs are designed to be globally unique without requiring a registration authority or coordination between the systems generating them. A GUID (Globally Unique Identifier) is Microsoft's implementation of the same standard — the terms are interchangeable in practice.
UUID v1 vs. UUID v4 — Which Should You Use?
- UUID v1 (time-based) — Combines the current timestamp with the MAC address of the generating machine. Because the timestamp is embedded, v1 UUIDs sort chronologically. The downside is that they can leak information about when and where they were created, which may be a privacy or security concern.
- UUID v4 (random) — Generated from 122 bits of random data (the remaining 6 bits are reserved for version and variant flags). There is no timestamp, no machine identifier, and no predictability. For the vast majority of use cases — database primary keys, session tokens, file names — UUID v4 is the right choice.
The Math Behind Uniqueness
UUID v4 has 2122 possible values — approximately 5.3 undecillion (5.3 × 1036). To put that in perspective, if you generated one billion UUIDs per second continuously, you would need to run for roughly 10 billion years before the probability of a single collision reached 50%. For practical engineering purposes, UUID v4 collisions are not a concern you need to plan around.
How to Generate UUIDs — Step by Step
- Open the UUID Generator — no login, no install required.
- Choose your version — v4 (random) for most uses, v1 (time-based) when you need sortable IDs.
- Set the quantity — generate a single UUID or a bulk batch for database seeding.
- Click Generate — the UUIDs are created entirely in your browser using
crypto.getRandomValues()for v4. - Copy the output directly into your code, SQL script, or config file.
Common Use Cases
- Database primary keys — Unlike auto-incrementing integers, UUID primary keys work across distributed databases and microservices without collision, and they don't reveal your table's row count to clients.
- Session tokens — A UUID v4 makes a solid session identifier because its randomness is cryptographically sound and it carries no deducible information about the user or timing.
- File naming — Uploading user-generated files to cloud storage with UUID filenames prevents name collisions and obscures the original filename from the URL.
- API request IDs — Attaching a UUID to outbound API requests enables end-to-end tracing and deduplication across distributed logs.
- Seeding test databases — Use bulk generation to create hundreds of unique IDs at once for populating development or staging data fixtures.
If you need a hashed representation of a UUID, the Hash Generator can run it through SHA-256 or MD5 instantly. For generating secure random strings that serve as passwords or secrets rather than identifiers, use the Password Generator. And for encoding a UUID as a Base64 string to embed in a URL or header, visit Base64 Encode/Decode.