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

VersionDerived fromNotes
v1Timestamp + MAC addressSortable, but leaks the generating host's MAC
v3MD5 of a namespace + nameDeterministic: same input always yields the same UUID
v4Random122 random bits; the default nearly everywhere
v5SHA-1 of a namespace + nameDeterministic; preferred over v3
v7Unix timestamp + randomTime-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.

All developer tools