Every dayRandom Generators

UUID
generator.

Make version 4 or version 7 UUIDs, or decode one to see its version and creation time.

How it's worked out

A UUID is 128 bits, written as 32 hex digits in groups of 8, 4, 4, 4 and 12. RFC 9562, published in 2024, sets out the versions. Two places are fixed in every standard UUID: the 13th digit is the version, and the first bits of the 17th digit are the variant, 10 in binary, which makes that digit 8, 9, a or b.

A version 4 UUID fills the other 122 bits with random data. This tool takes them from crypto.getRandomValues, the same cryptographic source as crypto.randomUUID in browsers.

A version 7 UUID starts with the Unix time in milliseconds, in 48 bits, so IDs made later sort later. The next 12 bits here hold a counter. It starts at a random value below 2,048 and goes up by one for each ID in a batch, which is one of the methods RFC 9562 gives to keep IDs in order within the same millisecond. The last 62 bits are random.

The chance that a set of random IDs holds a repeat follows the birthday problem.

p\displaystyle p≈1−e−n(n−1)2b+1\displaystyle {}\approx 1 - e^{-\frac{n(n-1)}{2^{b+1}}}

Here n is the number of IDs and b the random bits in each. For version 4, b is 122, so a 50% chance of a single repeat takes about 2.7 × 10¹⁸ IDs.

Worked examples

Reading the time inside a version 7 UUID

RFC 9562 gives 017f22e2-79b0-7cc3-98c4-dc0c0c07398f as its sample version 7 UUID. The 13th digit is 7, the version. The 17th digit is 9, whose first two bits are 10, the standard variant.

The first 12 digits, 017f22e279b0, are the time: 1,645,557,742,000 milliseconds after the start of 1970, which is 2022-02-22 19:22:22 UTC. Anyone who sees this ID can work out when it was made, to the millisecond.

Open this example in the tool

A version 1 UUID from an older system

The RFC’s version 1 sample is c232ab00-9414-11ec-b3c8-9f6bdeced846. Its time is split across three fields and counts steps of 100 nanoseconds from 15 October 1582. Put back together, it gives 2022-02-22 19:22:22 UTC, the same moment as the version 7 sample.

The last 12 digits, 9f6bdeced846, are the node field. RFC 9562 says it holds a network card address or a random value, so an old version 1 ID can point to the machine that made it. The RFC also says to use version 7 instead of version 1 where possible.

Open this example in the tool

Priya makes 1,000 test keys

Priya needs 1,000 primary keys for a test table. One version 7 batch made at 2026-11-10 09:30:00 UTC gives IDs from 01a1c4ca-fdc0-721e-b1ff-fcf0f4091c27 to 01a1c4ca-fdc0-7605-985a-18c59bd9c635. Sorted as text, they come out in the order they were made, because they share the time and the counter goes up by one.

Checked line by line, 1,000 of them are valid version 7 IDs with that time, and none repeats. Had she used version 4, the chance of any repeat among 1,000 would be 9.4 × 10⁻³², and among a billion still only 9.4 × 10⁻²⁰.

Reading your result

What the 13th digit says
DigitVersionWhat it holds
1Version 1Time and node
3Version 3MD5 hash of a name
4Version 4Random bits
5Version 5SHA-1 hash of a name
6Version 6Time, reordered to sort
7Version 7Unix time, then random
8Version 8Custom layout

Check the variant first. The version digit only means something when the 17th digit is 8, 9, a or b. Digits 0 to 7 belong to an old NCS layout, c and d to an old Microsoft one, and e and f are reserved.

Version 4 or version 7. Pick version 7 for database keys and logs, where sorting by time keeps new rows close together in an index. Pick version 4 when an ID must not reveal when it was made, such as a public link to a record.

Nil and Max. The Nil UUID is all zeros and the Max UUID is all f digits. Both are reserved values, often used to mean none or the end of a range.

Common mistakes

  • Treating a UUID as a password. RFC 9562 says not to assume UUIDs are hard to guess and not to use them as security capabilities, IDs whose mere possession grants access. Use a dedicated random token for sign-in links and API keys.
  • Comparing UUIDs as plain text. One system may write uppercase in braces and another lowercase with hyphens. Convert both to one form before you compare, or the same ID looks like two.
  • Expecting a v7 batch to sort without a counter. If every ID in a batch shares the same millisecond and the rest is random, the batch sorts in a random order. A counter, as used here, fixes that.
  • Using version 1 on a public system. Its node field can hold the network card address of the machine that made it. Version 7 gives the same time ordering without that.
  • Writing your own generator with Math.random. A weak random source is the usual cause of real repeats. Use the platform’s cryptographic source, such as crypto.randomUUID in a browser.

Questions people ask

Version 7 is usually better for primary keys, because new IDs sort after old ones and inserts land near each other in the index. Version 4 scatters inserts across the index, which can slow writes on large tables. Use version 4 where revealing the creation time would matter.

Sources