What's a UUID?
What are Universal Unique Identifiers and how do they work?

Overview

UUID stands for Universally Unique Identifier (sometimes called "GUID" or "Globally Unique Identifiers"). UUIDs are 36 character strings containing numbers, letters and dashes. UUIDs are designed to be globally unique.

There are several UUID versions with slightly different purposes. In UUID version-4, which is completely random, there are approximately 5.3 x 1036 possible UUIDs. This number is so large that if you were to generate 1 billion UUIDs per second for 85 you have a 50% chance of creating a duplicate.

The chances of a duplicate UUID are so low it is safe to assume each ID will be unique. Separate computers can generate UUIDs at the same time with no communication and still be confident the UUIDs are unique. Independent systems that use UUIDs can be safely merged at any time without worrying about collisions.

This is an extremely useful property as many computer systems today are distributed.

UUIDs can be generated locally; there is no central authority for coordination or registration. UUIDs have the lowest minting cost of any system of unique identification. Most programming languages have a way to generate UUIDs which makes makes them useful for compatibility across systems.

You can even use an online UUID generator and still be confident the ID is globally unique.

UUID standards are formalized in RCF 4122 published in 2005.

UUID Format

UUIDs are written in 5 groups of hexadecimal digits separated by hyphens. The length of each group is: 8-4-4-4-12. UUIDs are fixed length. For example: 123e4567-e89b-12d3-a456-426655440000

UUIDs have 32 digits plus 4 hyphens for a total of 36 characters. UUIDs are fixed length. UUIDs are 128-bits in binary. (32 hex digits x 4 bits per hex digit = 128-bits).

UUIDs may also be represented in decimal or binary format.

FormatExample
Hexadecimal123e4567-e89b-12d3-a456-426655440000
Decimal190464649652423269416550308090595239059
Binary10001111 01001010 00101000 00111110 11111111 10100101 01001010 00100100 10100010 01110111 00000001 11000110 00001000 10010011 11100100 10010011

Can a UUID be repeated?

UUID collisions are extremely unlikely.

With UUID version-1 the MAC address of the computer generating the UUID in embedded in the UUID. MAC Addresses are unique on every computer with a network card. This makes it impossible for 2 different computers to generate the same UUID if both adhere to the specification. The timestamp is also including in the UUID to ensure uniqueness. The timestamp field will rollover in 5236 AD. So there is no chance of duplicate until then.

With version-4 there is an exceptionally small chance of duplicate.

With version-4 UUIDs, which are totally random, there are approximately 5.3 x 1036 possible UUIDs. With numbers that large the chances of any two people in the whole world ever generating the same UUID are astronomically small. The chances are so small that it is generally safe to assume it will never happen.

With version-3 and version-5, the UUID output is based on the input you provide. As long as the input provided is random, the chances of duplication are the same as for version-4.

Learn more about UUID Versions »

UUID Regular Expression (REGEX)

The regex below can be used to validate the format of UUIDs:

[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}

Are UUIDs Case-sensitive?

No, UUIDs are written in base 16 which uses numbers 0-9 and characters a-f. There is no distinction between upper and lowercase letters. However, RCF 4122 section 3 requires that UUID generators output in lowercase and systems accept UUIDs in upper and lowercase.