blog.stogas.dev

Determine UUID versions visually

 •  • Updated:  • small-tips, development

Some people know that UUIDs are not completely random (yes, even UUIDv4 - it's only mostly random), and that they encode which UUID version they are within themselves.

But did you know that you can identify the version at a glance, just by eyeballing it?

RFC 9562 states:

The version number is in the most significant 4 bits of octet 6 (bits 48 through 51 of the UUID).

In the regular, human-readable representation, that's the first digit of the middle group.

Or, to make it even simpler: this digit right here is the version:

00000000-0000-X000-0000-000000000000
              ^

For example:

c232ab00-9414-11ec-b3c8-9f6bdeced846 # UUIDv1
              ^
919108f7-52d1-4320-9bac-f847db4148a8 # UUIDv4, probably the most common version
              ^
017f22e2-79b0-7cc3-98c4-dc0c0c07398f # UUIDv7
              ^