A UUID (Universally Unique Identifier) is a 128-bit label used to uniquely identify information in computer systems. You will encounter UUIDs in database primary keys, API resources, file names, session tokens, and countless other contexts. The key promise of a UUID is that it can be generated independently on any machine without coordination and the result will still be globally unique.
What Does a UUID Look Like?
A UUID is represented as 32 hexadecimal digits arranged in five groups separated by hyphens: 550e8400-e29b-41d4-a716-446655440000. There are five versions of UUID (v1 through v5) and a newer v6, v7, v8 standard. Version 4 is by far the most commonly used today because it is entirely random and carries no identifying information about the machine that generated it.
UUID v1 vs UUID v4
UUID v1 is generated using the current timestamp and the MAC address of the network interface. This makes it sortable chronologically but potentially privacy-sensitive since the MAC address is embedded in the identifier.
UUID v4 is generated using random numbers. There is no timestamp, no MAC address, no machine-identifiable information. For most use cases, v4 is the correct choice.
How Many UUIDs Are There?
Version 4 UUIDs have 122 bits of randomness. That gives approximately 5.3 undecillion possible values (5.3 times 10 to the power of 36). The probability of generating two identical UUIDs is astronomically small. In practice it is safe to treat UUID v4 as unique without any coordination mechanism.
When Should You Use UUIDs?
UUIDs work well as primary keys in distributed databases where multiple servers need to generate IDs without talking to a central sequence generator. They work well as API resource identifiers because they do not expose the number of records in your database (unlike auto-incrementing integer IDs). They are also the standard choice for session tokens, file upload identifiers, and any other place where you need a unique opaque identifier.
How to Generate a UUID with DevHexLab
Open the UUID Generator at /tools/developer/uuid-generator. The tool generates a new UUID v4 every time you click Generate. Set the count field to generate several at once. Click Copy to grab one or all of them.
Everything runs in your browser. No server call is made.
Frequently Asked Questions
Are UUID and GUID the same thing?
Essentially yes. GUID stands for Globally Unique Identifier and is Microsoft's terminology. A GUID follows the same format and the same Version 4 random generation. The DevHexLab GUID Generator produces identifiers in the format expected by Microsoft tools.
Can I use a UUID as a database primary key?
Yes. This is a very common pattern. One consideration is that random UUIDs cause random insertion order in B-tree indexes, which can affect write performance in large tables. UUID v7 (time-ordered UUIDs) addresses this but is not yet widely supported in generators.
Is a UUID guaranteed to be unique?
Not mathematically guaranteed, but the probability of collision is so low it is negligible in any real application.
Generate a UUID and use it. The randomness is handled for you.