UUID v4 Explained: How Random UUIDs Are Generated and Used
Understand UUID v4 structure, how 122 bits of randomness are generated, collision probability, and when to use v4 over other UUID versions.
Published:
Tags: developer-tools, uuid, explainer
UUID v4 Explained: How Random UUIDs Are Generated and Used UUID v4 is the most widely used unique identifier format in software today. It is simple, stateless, and requires no coordination across generators. But "random UUID" understates what is actually happening — understanding the structure, the randomness source, and the failure modes makes you a more deliberate engineer. This post covers all of it. --- The Structure of a UUID v4 A UUID is 128 bits. In the canonical text representation, those bits are displayed as 32 hex characters in five groups: Every position in that string carries meaning defined by RFC 4122: | Field | Bits | Notes | |---|---|---| | | 32 | Random in v4 | | | 16 | Random in v4 | | | 16 | Top 4 bits = (version 4), rest random | | | 8 | Top 2 bits = (variant), rest…
All articles · theproductguy.in