UUID v2 is unspecified, so no official generator can be given.

Instead, consider UUID v4, UUID v1, or other ID generators.

What is different about UUID v2

UUID v2 is a variant of UUID v1, which is a timestamp-based UUID.

However, as presented in RFC 4122, no specific implementation is provided.

UUID v2 should be avoided in favor of its more commonly used alternatives, like UUID v1 and UUID v4.

What is a UUID?

A UUID is a Universally Unique IDentifier. It is a 128-bit number used to uniquely identify something. It is usually represented as a 32-character hexadecimal string with hyphens.

UUIDs come in several versions. The most frequent is v4, which is randomly generated. This is the version used by this page.

Why use UUIDs?

UUIDs are meant to be Universally Unique. This means you should be able to generate a UUID anywhere and be confident that it will not collide with another UUID generated anywhere else.

UUIDs are also instantly recognizable as IDs. This makes them easy to pick out in logs or other text.

Some databases (for example, Postgres) can also efficiently represent UUIDs as 128 bit integers instead of 288 bit strings. This makes them suitable for use as primary keys without a significant performance penalty.

What are some negatives of UUIDs?

UUIDs are not guaranteed to be unique, instead they are given a certain (typically very low) probability of collision. The probability of generating two UUIDs (especially v4 or v7) that collide is very low, but not zero.

UUIDs can also leak information about the underlying system that generated them. For example, the MAC address of the network interface card can be used to generate a UUID. This can be used to track a device across networks.

There are several alternatives to UUIDs with various tradeoffs. For a review, see our article (coming soon).