UUID Generator
Generate universally unique identifiers and inspect the structure of an existing one. A UUID is 128 bits, conventionally written as 32 hexadecimal digits in five hyphen-separated groups: 8-4-4-4-12.
Versions in common use
| Version | Derived from | Notes |
|---|---|---|
| v1 | Timestamp + MAC address | Sortable, but leaks the generating host's MAC |
| v3 | MD5 of a namespace + name | Deterministic: same input always yields the same UUID |
| v4 | Random | 122 random bits; the default nearly everywhere |
| v5 | SHA-1 of a namespace + name | Deterministic; preferred over v3 |
| v7 | Unix timestamp + random | Time-sortable without leaking hardware identity |
Collision probability
A v4 UUID carries 122 random bits, six being fixed for version and variant. You would need to generate on the order of a billion UUIDs per second for roughly a century before a collision became likely. In practice the realistic failure mode is not mathematics but a weak random source — a poorly seeded PRNG, or an embedded device with no entropy at boot.
v4 or v7 as a database key
Random v4 UUIDs make poor primary keys in B-tree indexes: each insert lands at a random point in the index, fragmenting pages and destroying cache locality. UUID v7 prefixes a millisecond timestamp, so newly generated values sort near each other and insert behaviour resembles an auto-incrementing integer while remaining globally unique.