Online GUID / UUID Generator

Free Online GUID / UUID Generator! The essential resource for developers, testers, and database administrators.
Format:
Encoding:
?
?
?
    

Use these GUIDs at your own risk! No guarantee of their uniqueness or suitability is given or implied.

Your Daily Fortune


All About UUIDs

Dealing with primary keys and unique identifiers is one of those "solved" problems that actually keeps coming up every time you scale your architecture. Whether you're designing a distributed system, a REST API, or a massive PostgreSQL cluster, you eventually hit the wall where AUTO_INCREMENT integers stop working. That is where the UUID comes in.

What is a UUID or GUID?

At its core, a UUID (Universally Unique Identifier) is a 128-bit number used to uniquely identify information in computer systems. When you see one in a log file, a database, or a JSON response, it's usually represented as a string of 32 hexadecimal digits, displayed in five groups separated by hyphens (the 8-4-4-4-12 format), like this: 550e8400-e29b-41d4-a716-446655440000.

You will often hear the term GUID (Globally Unique Identifier). For almost all practical purposes, a GUID is just Microsoft's implementation of the UUID standard. While there are slight historical differences in how they were generated—specifically regarding how Microsoft handled the timestamp and clock sequence in early versions—in a modern dev environment, the terms are interchangeable.

The "Universal" part of the name is the key. The goal of a UUID is to allow any developer, on any machine, in any timezone, to generate an ID without needing to check with a central authority (like a database server) to see if that ID is already taken. It is a shift from centralized coordination to probabilistic uniqueness.

Who Uses UUIDs?

Pretty much everyone operating at scale. If your project is a simple CRUD app for a local bakery with three users, a standard integer ID is fine. But for the following roles, UUIDs are the professional standard:

  • Backend Engineers: Especially those building microservices. When Service A creates a record and Service B needs to reference it, having a UUID prevents "ID collisions" when merging data from different sources. It allows services to communicate via "opaque identifiers" that don't reveal internal database logic.
  • Database Administrators (DBAs): DBAs use UUIDs to facilitate data sharding and replication. In a sharded environment, if you use integers, you have to coordinate the "offset" for each shard (e.g., Shard 1 uses 1-1M, Shard 2 uses 1M-2M) to avoid duplicates. UUIDs eliminate this orchestration entirely.
  • Frontend/Mobile Developers: UUIDs allow a mobile app to generate an ID for a new record offline. If a user creates a "Note" while in airplane mode, the app can assign it a UUID immediately. When the app syncs to the server later, the record already has its permanent ID, preventing the "double-insert" problem that occurs when waiting for a server-generated ID.
  • QA and Testers: When generating synthetic test data or automating thousands of API calls across parallel CI/CD pipelines, UUIDs ensure that test entities don't collide across different test environments or concurrent runs.
  • Security Engineers: By replacing predictable integer IDs with UUIDs in URLs, security teams prevent "Insecure Direct Object Reference" (IDOR) vulnerabilities. An attacker cannot simply change user/100 to user/101 to scrape your entire user database.

How is it Used?

UUIDs are typically deployed in three primary patterns: as Primary Keys, Correlation IDs, and Opaque Tokens.

1. Database Primary Keys

Instead of UserID: 101, you have UserID: f47ac10b-58cc-4372-a567-0e02b2c3d479. This is the most common use case. By moving the ID generation to the application layer (the code) rather than the database layer (the SERIAL or AUTO_INCREMENT column), you reduce the load on the database and make your application more resilient.

2. Distributed Tracing (Correlation IDs)

In a microservice mesh, a single user request might touch ten different services (Auth \(\rightarrow\) Gateway \(\rightarrow\) Order \(\rightarrow\) Payment \(\rightarrow\) Shipping). A "Correlation UUID" is generated at the API Gateway and passed in the HTTP header of every internal request. If the request fails at the Payment service, you can search your centralized logging system (like ELK or Splunk) for that specific UUID and see the entire lifecycle of that request across all services.

3. Session and API Management

Using UUIDs for session tokens or API keys ensures that the tokens are mathematically impossible to guess. Unlike a sequence, a UUID provides no information about when the token was created or how many tokens exist.

4. Immutable File Naming

When users upload files to cloud storage (S3, Azure Blob), renaming my_resume.pdf to a UUID prevents filename collisions. If two users both upload image.jpg, the second one won't overwrite the first because they are stored as a1b2...jpg and c3d4...jpg.

When and Why Were They Created?

The need for UUIDs arose from the inherent limitations of centralized ID generation. In the early days of networking, if you wanted a unique ID, you asked a central server for the "next available number." This created a Single Point of Failure (SPOF) and a massive performance bottleneck. As you added more servers, the "ID server" became the slowest part of the system.

As distributed computing grew—specifically with the rise of object-oriented systems and networked workstations—we needed a way to guarantee uniqueness probabilistically. The standard was formalized by the Open Software Collaboration (OSC) and later by the IETF (Internet Engineering Task Force) in RFC 4122.

The "Why" boils down to three fundamental engineering needs:

  1. Decentralization: The ability to generate IDs without a network round-trip.
  2. Dataset Merging: The ability to take two separate databases—perhaps from two different companies during a merger—and combine them into one table without a single ID conflict.
  3. Security via Obscurity: Hiding the internal scale of the system. If your URL is /orders/500, a competitor knows you've had 500 orders. If it's /orders/b2a1..., they know nothing.

How Unique Are They in the Real World?

The most common pushback from developers is: "What if two people generate the same UUID at the same time?" To answer this, we have to stop thinking in human terms and start thinking in binary.

A UUID has 128 bits. For a version 4 UUID (the most common random type), 122 of those bits are randomly generated. That means there are \(2^{122}\) possible combinations. To visualize this: if you generated 1 billion UUIDs every second for the next 100 years, the probability of creating just one collision is so infinitesimally small that it is effectively zero.

You are significantly more likely to be hit by a meteorite while winning the lottery than you are to experience a UUID collision in a production environment.

However, in the real world, "collisions" do happen, but they are almost never the fault of the UUID standard. They are the result of implementation failures:

  • Poor PRNGs: If a developer uses a non-cryptographic random number generator seeded with the current second, two servers starting at the same time might produce the same sequence of "random" numbers.
  • Virtual Machine Cloning: If a VM is cloned while the OS is running, the internal state of the random number generator might be cloned as well, leading both VMs to generate the same "random" IDs.

This is why using a cryptographically secure random number generator (CSPRNG) is non-negotiable.

Are UUIDs Suitable for Databases?

This is where the debate gets heated. The short answer: Yes, but if you do it blindly, you will destroy your database performance.

The Fragmentation Problem (The B-Tree Nightmare)

Most relational databases (MySQL, SQL Server, PostgreSQL) use B-Tree indexes for primary keys. B-Trees thrive on sequential data. When you use an integer (1, 2, 3...), the database simply appends the new row to the end of the index. This is a highly efficient "append-only" operation.

Random UUIDs (v4) are, by definition, non-sequential. When you insert a random UUID, the database must find the exact alphabetical/numerical spot for that ID and "shove" it into the middle of the index. This causes Page Fragmentation. The database has to split pages and move data around on the disk to make room. As the table grows to millions of rows, this leads to massive I/O overhead, causing write speeds to plummet.

Storage Overhead

Storage is cheap, but RAM is not. An integer is 4 bytes. A big-int is 8 bytes. A UUID is 16 bytes (when stored as binary). While 16 bytes sounds negligible, remember that the primary key is duplicated in every single Foreign Key in your database.

If you have a Users table and an Orders table with 100 million rows, the difference between an 8-byte key and a 16-byte key is gigabytes of extra data. This increases the size of your indexes, which in turn means fewer index entries fit in the RAM buffer pool, forcing the database to read from the slow disk more often.

The Professional Solution

To make UUIDs production-ready:

  1. Store as Binary: Never store UUIDs as strings (VARCHAR(36)). A string takes 36 bytes; a binary representation takes 16. In MySQL, use BINARY(16). In PostgreSQL, use the native UUID type.
  2. Use Sequential/Time-Ordered UUIDs: This is the "secret sauce." By using UUIDs that start with a timestamp (like UUID v7), you maintain global uniqueness but regain the sequential nature of integers. The database can once again append to the end of the B-Tree, eliminating fragmentation.

Comparison of UUID Types

Not all UUIDs are created equal. Choosing the wrong version can lead to privacy leaks or performance bottlenecks.

UUID Version 1: The Timestamp & MAC approach

v1 generates IDs based on the current time and the MAC address of the machine.

  • Pros: Extremely low collision risk; naturally sortable by time.
  • Cons: Privacy Leak. Because the MAC address is embedded in the ID, anyone who can see the UUID can identify the physical machine that created the record. This is a non-starter for public-facing APIs.

UUID Version 3 & 5: The Name-based (Deterministic) approach

These are not random. They are created by hashing a "namespace" (like a URL) and a "name" (like a username). v3 uses MD5; v5 uses SHA-1.

  • Pros: Deterministic. If you hash the same input twice, you get the same UUID. This is incredibly useful for mapping identifiers between two different systems without storing a lookup table.
  • Cons: Not random. If someone knows your namespace and the input, they can recreate the UUID.

UUID Version 4: The Random approach

The "industry standard." It is almost entirely random.

  • Pros: Simple to generate; no privacy concerns; no coordination required.
  • Cons: The "B-Tree Nightmare." Terrible for database indexing due to randomness.

UUID Version 7: The Modern Standard (Time-Ordered)

v7 is the current recommendation for software architects. It combines a Unix timestamp (at the start) with random data (at the end).

  • Pros: Lexicographically sortable. It behaves like an integer for the database index (no fragmentation) but remains globally unique and secure.
  • Cons: Relatively new; some legacy libraries might not have a uuid_v7() function yet, requiring a small custom implementation.

FAQ: Technical Deep Dive for Developers

Q: "I'm using MongoDB. Do I need UUIDs?"

A: MongoDB uses ObjectId by default, which is actually a hybrid similar to UUID v1 (timestamp + machine ID + counter). If you are staying within the Mongo ecosystem, ObjectId is sufficient. However, if you are syncing Mongo data to a SQL warehouse or an external API, converting those to standard UUIDs is better for interoperability.

Q: "Does using a UUID slow down my SELECT queries?"

A: In a vacuum, yes. Comparing two 128-bit numbers is marginally slower than comparing two 32-bit integers. However, in a real system, the performance hit comes from the cache miss rate. Because random UUIDs scatter data across the disk, your CPU cache and RAM buffer pool become less effective, leading to more disk I/O.

Q: "Can I use Base64 to make my UUIDs shorter in URLs?"

A: You can, but be careful. A standard UUID is 36 characters. Converting it to Base64 reduces it to 22 characters. However, standard Base64 includes + and /, which are reserved characters in URLs. You must use "URL-Safe Base64" (replacing + with - and / with _) to avoid routing errors.

Q: "What is the performance impact of generating a UUID in a tight loop?"

A: The bottleneck is usually the entropy source. Cryptographically secure random number generators (CSPRNGs) pull from the OS entropy pool (e.g., /dev/urandom). In extremely high-throughput systems (millions of IDs per second), this can occasionally cause contention. In those rare cases, developers use a hybrid approach: a single seed from the OS, then a fast user-space generator.

Q: "If I'm using a distributed database like Cassandra or DynamoDB, do I still need UUID v7?"

A: Less so. NoSQL databases often use LSM-Trees (Log-Structured Merge-Trees) instead of B-Trees. LSM-Trees handle random writes much better than B-Trees do. In these systems, UUID v4 is perfectly acceptable.

Architectural Implementation Checklist

If you are designing a system today, here is the professional blueprint for handling identifiers:

  1. Primary Keys: Use UUID v7. Store them as Binary(16) or the native UUID type. This ensures your database remains performant as you grow to billions of rows.
  2. Public APIs: Expose these UUIDs as hyphenated strings. Do not expose your internal integer IDs.
  3. Distributed Tracing: Implement a Correlation UUID at your entry point (API Gateway). Ensure this ID is passed in every internal gRPC or HTTP call and included in every log entry.
  4. Offline Sync: Allow your mobile/frontend clients to generate their own UUIDs. Treat the client as the "source of truth" for the ID, and have the server simply validate it.
  5. Security: Always use a CSPRNG (e.g., crypto.randomUUID() in JS, Guid.NewGuid() in .NET, uuid.uuid4() in Python). Never use Math.random() or similar basic functions.

By following this pattern, you eliminate the fragility of centralized ID generation, protect your system from enumeration attacks, and ensure that your persistence layer can scale horizontally without the dreaded "re-indexing" migrations.

More Information About GUIDs

Globally Unique Identifier - Wikipedia, the free encyclopedia
GUID Structure - Microsoft.com
RFC 9562 (2024-05) RFC 4122 (2005-07)