# UUID generator and decoder (v4, v7)

> Generate reproducible UUID v4 and v7 values from a seed, or validate any UUID or GUID and decode its version, variant and embedded timestamp.

Interactive version: https://www.calcopenly.com/programming/uuid-decoder-generator
Subject: Programming and tech calculators

A UUID is a 128-bit identifier written as 32 hex digits in 8-4-4-4-12 groups. RFC 9562 fixes two fields in every standard UUID: the variant bits 10 at the start of the 17th hex digit, and a 4-bit version number in the 13th. The decoder reads both, then unpacks what that version carries: a 48-bit Unix millisecond timestamp for version 7, a 60-bit count of 100-nanosecond intervals since 15 October 1582 for versions 1 and 6, or 122 random bits for version 4.

The default is the RFC 9562 version 7 example, 017f22e2-79b0-7cc3-98c4-dc0c0c07398f, whose first 48 bits count 1,645,557,742,000 ms, which is 22 February 2022 at 19:22:22 UTC. Developers pick v7 for database keys because the values sort by creation time.

Generated UUIDs come from a seeded xoshiro256** generator, so the same seed always gives the same list. For identifiers that must be unguessable, use a cryptographic source such as crypto.randomUUID().

## Inputs

- **I want to** (options: Decode a UUID, Generate UUIDs)
- **UUID**: Upper or lower case, with or without hyphens, braces or a urn:uuid: prefix.
- **Version** (options: v4 (random), v7 (time-ordered))
- **Seed**: A whole number from 0 to 2^64 − 1; the same seed always gives the same UUIDs.
- **How many**
- **Timestamp date (UTC)**
- **Timestamp time (UTC)**

## Results

- UUID — main result
- Type
- Version
- Variant
- Embedded time
- Unix time (ms)
- Clock sequence
- Node
- Generated UUIDs

## Formula

$$
\begin{aligned} \text{v7: } t_{ms} &= \text{bits } 0\text{–}47 \\ \text{v1/v6: } t &= \frac{\text{60-bit count}}{10^7} \\ &\quad - 12\,219\,292\,800\ \text{s} \end{aligned}
$$

## Worked examples

### RFC 9562 version 7 example

- I want to: Decode a UUID
- UUID: 017F22E2-79B0-7CC3-98C4-DC0C0C07398F
- **UUID: 017f22e2-79b0-7cc3-98c4-dc0c0c07398f**
- **Version: 7**
- **Variant: RFC 9562**
- **Embedded time: 2022-02-22 19:22:22.000 UTC**
- **Unix time: 1645557742000 ms**
- Checked against: RFC 9562 Appendix A.6 (Tuesday, February 22, 2022 2:22:22.00 PM GMT-05:00); Python 3.8: int('017F22E279B0', 16) = 1645557742000

### RFC 9562 version 4 example

- I want to: Decode a UUID
- UUID: 919108f7-52d1-4320-9bac-f847db4148a8
- **Version: 4**
- **Type: Random**
- **Variant: RFC 9562**
- Checked against: RFC 9562 Appendix A.3; Python 3.8 uuid.UUID(...).version = 4, .variant = 'specified in RFC 4122'

### RFC 9562 version 1 example

- I want to: Decode a UUID
- UUID: C232AB00-9414-11EC-B3C8-9F6BDECED846
- **Version: 1**
- **Embedded time: 2022-02-22 19:22:22.0000000 UTC**
- **Clock sequence: 13,256**
- **Node: 9f:6b:de:ce:d8:46**
- Checked against: RFC 9562 Appendix A.1; Python 3.8 uuid.UUID(...).time = 138648505420000000, (time − 122192928000000000) / 10^7 = 1645557742 s; .clock_seq = 13256; .node = 0x9f6bdeced846

### RFC 9562 version 6 example

- I want to: Decode a UUID
- UUID: 1EC9414C-232A-6B00-B3C8-9F6BDECED846
- **Version: 6**
- **Embedded time: 2022-02-22 19:22:22.0000000 UTC**
- Checked against: RFC 9562 Appendix A.5 (same instant as the v1 example)

### Nil UUID with braces and a URN prefix (edge)

- I want to: Decode a UUID
- UUID: urn:uuid:{00000000-0000-0000-0000-000000000000}
- **UUID: 00000000-0000-0000-0000-000000000000**
- **Type: Nil UUID**
- Checked against: RFC 9562 §5.9 (Nil UUID: all 128 bits zero) and §4 (urn:uuid: form)

### Max UUID (edge)

- I want to: Decode a UUID
- UUID: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
- **UUID: ffffffff-ffff-ffff-ffff-ffffffffffff**
- **Type: Max UUID**
- Checked against: RFC 9562 §5.10 (Max UUID: all 128 bits one)

## Questions

### What is the difference between UUID v4 and v7?

Version 4 fills 122 of the 128 bits with random data, so values are spread evenly and reveal nothing. Version 7, defined in RFC 9562 (May 2024), puts a 48-bit Unix millisecond timestamp first and 74 random bits after it, so new IDs sort in creation order. RFC 9562 notes that v4 has poor database-index locality, which is why v7 suits primary keys, at the cost of revealing when each ID was made.

### Can two random UUIDs collide?

In practice, no. A v4 UUID has 122 random bits, so by the birthday bound you would need about 2.7 × 10^18 of them for a 50% chance of a single duplicate, or about 103 trillion for a one-in-a-billion chance. Real collisions come from faulty random number generators or reused seeds, which is why the seeded UUIDs here shouldn't be used where uniqueness across systems matters.

### What is the difference between a UUID and a GUID?

They are the same 128-bit format; GUID is Microsoft's name for it. Microsoft tools often print GUIDs in upper case inside braces, such as {017F22E2-79B0-7CC3-98C4-DC0C0C07398F}, and RFC 9562 allows upper, lower or mixed case, so parsers should accept both. The one real difference is binary byte order: Windows stores the first three groups little-endian, which matters only when reading raw bytes.

### How do I get the timestamp from a UUID v7?

Take the first 12 hex digits, which hold a 48-bit count of milliseconds since 1970-01-01 00:00 UTC, and convert them to decimal. For 017f22e2-79b0-7cc3-98c4-dc0c0c07398f, 017f22e279b0 is 1,645,557,742,000 ms, which is 2022-02-22 19:22:22.000 UTC. The 48-bit field runs out in the year 10889, so it will not wrap in practice.

### Is a version 1 UUID a privacy risk?

It can be. Version 1 stores a 60-bit timestamp and a 48-bit node field that is traditionally the machine's MAC address, so the ID reveals when and on which network card it was made; the RFC 9562 v1 example decodes to 2022-02-22 19:22:22 UTC with node 9f:6b:de:ce:d8:46. RFC 9562 allows a random node value instead, and says to use version 7 instead of 1 or 6 where possible.

### How accurate is the UUID generator and decoder?

Accuracy depends on your inputs and the method's assumptions. Decimal arithmetic uses 50 significant digits, but estimates, numerical methods and source data can be less precise; the displayed rounding does not remove those limits. It is checked against 8 worked examples whose answers come from independent sources; for example, “RFC 9562 version 7 example” is checked against RFC 9562 Appendix A.6 (Tuesday, February 22, 2022 2:22:22.00 PM GMT-05:00); Python 3.8: int('017F22E279B0', 16) = 1645557742000.

### Where does the method come from?

RFC 9562 — Universally Unique IDentifiers (UUIDs), §4–5 and Appendix A test vectors; Blackman & Vigna — xoshiro256** and SplitMix64 reference code.

## Sources

- [RFC 9562 — Universally Unique IDentifiers (UUIDs), §4–5 and Appendix A test vectors](https://www.rfc-editor.org/rfc/rfc9562)
- [Blackman & Vigna — xoshiro256** and SplitMix64 reference code](https://prng.di.unimi.it/)
