CoShareX Logo
HomeBlogUtilitiesUnderstanding UUIDs: What Is UUID v4 and How Does It Work?
Utilities

Understanding UUIDs: What Is UUID v4 and How Does It Work?

Published 2026-08-19
3 min read
By CoShareX

A Universally Unique Identifier (UUID) is a 128-bit label used for information in computer systems. The term Globally Unique Identifier (GUID) is also used, matching Microsoft's terminology.

In this guide, we'll look at the details of version 4 UUIDs (randomly generated) and how they prevent database key collisions.

What is a UUID v4?

Unlike version 1 (which relies on timestamp and MAC addresses) or version 3/5 (which are namespace-based), version 4 UUIDs are generated entirely using random (or pseudo-random) numbers.

Of the 128 bits, 4 bits are used to indicate the version (always 4), and 2 to 3 bits indicate the variant (usually RFC 4122 variant 1). This leaves 122 bits of pure randomness, giving a total of:

$$2^{122} \approx 5.3 \times 10^{36}$$

possible unique identifiers.

Featured Tool

UUID Generator

Generate cryptographically secure UUID (GUID) v4 strings online. Bulk generate unique identifiers with uppercase, lowercase, and hyphen options.

The Standard Format

A UUID is represented as 32 hexadecimal digits, displayed in five groups separated by hyphens, in the form 8-4-4-4-12:

text
1
f81d4fae-7dec-11d0-a765-00a0c91e6bf6

In version 4, the digit at the start of the third group is always 4:

text
1
xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx

Where y must be one of 8, 9, a, or b according to RFC 4122.

UUID Collision Risks

The probability of a duplicate version 4 UUID is extremely close to zero. To get a 50% chance of a collision, you would need to generate 2.71 quintillion UUIDs, which is well beyond ordinary database sizes.