Skip to content
Browser tool Runs locally

Generator Tools

Create QR codes, identifiers, passwords, placeholder text, and URL-friendly slugs in your browser.

Tools

UUID v4 vs. time-based versions

UUID Generator produces version 4 IDs: 122 bits of cryptographically secure randomness, with no timestamp or machine identifier embedded anywhere in them. That's different from time-based versions like v1 or the newer v7, which put a timestamp in the leading bits so that IDs generated later sort after ones generated earlier. Time ordering helps database index performance at scale, but it also means the ID reveals roughly when it was created, which v4's pure randomness never does.

UUID v7, briefly

UUID v7 is a newer, standardized version built specifically to be sortable: it starts with a millisecond-precision timestamp and fills the rest with random bits. Generated in sequence, v7 IDs come out in roughly chronological order, which some databases index more efficiently than the scattered order v4 produces. It's a reasonable choice when insertion order matters for performance; this generator creates v4, the right default when you specifically don't want creation time encoded in the identifier.

Why uniqueness is probabilistic, not guaranteed

No fixed-length random ID can offer an absolute mathematical guarantee against collision, there are only ever finitely many possible values. What UUID v4 offers instead is a very small collision probability at ordinary volumes, provided values are generated independently with a suitable random source. That probability rises with the total number generated: a billion values every second for roughly 85 years brings it close to 50%. Keep a uniqueness constraint and handle duplicate insertion wherever a collision would cause an incorrect result.

Frequently asked questions

What is a UUID, and why use one instead of an incrementing ID?
A UUID (Universally Unique Identifier) is a 128-bit value that any system can generate on its own, with no central authority or database handing out the next number. That's the advantage over an auto-incrementing integer: two services, two database shards, or an offline client can each mint IDs independently with no coordination and no risk of two systems handing out the same value.
What makes UUID v4 different from time-based versions like v1 or v7?
V4 is pure randomness: 122 bits of random data with no timestamp or machine identifier embedded. Time-based versions like v1 and v7 encode the creation time in the leading bits, which means IDs generated later sort after ones generated earlier. That ordering is convenient for database indexing, but it also means the UUID reveals when it was created, something v4 never does.
What is UUID v7, at a high level?
A newer, standardized UUID version that leads with a millisecond-precision timestamp followed by random bits. Because the timestamp comes first, v7 UUIDs generated in sequence sort in roughly chronological order, which helps database index performance compared to the effectively random ordering of v4. This generator produces v4 IDs; if an application specifically calls for time-ordered identifiers, that's the version to look for elsewhere.
If UUIDs aren't guaranteed unique, why do we treat them as unique?
UUID v4 has 122 random bits, so independently and uniformly generated values have a very small collision probability at ordinary volumes. The probability rises with the total number generated: a billion values per second for roughly 85 years brings it close to 50%. Enforce uniqueness and handle duplicate insertion when your application requires it; a UUID is an identifier, not an authentication credential.
When should I use a UUID instead of a shorter ID?
When IDs need to be generated in more than one place without coordination, like client-side, across services, or offline, or when you don't want an ID's format to leak how many records exist or in what order. If you only need a short, human-typeable code, or IDs are always assigned by a single database that already guarantees uniqueness, a UUID is usually more than you need.