These examples let you check the output of a UUID parser or converter against known values. The v4, v5 and v7 values below come from the examples in RFC 9562. The assertions demonstrate how to reproduce the checks. They are not randomness or performance benchmarks.
Download the test vectors as JSON. These identifiers are public fixtures: never reuse them as unique production keys or secrets.
UUID examples with expected results
| UUID | Expected result |
|---|---|
| 017f22e2-79b0-7cc3-98c4-dc0c0c07398f | Version 7; Unix milliseconds 1645557742000; UTC 2022-02-22T19:22:22.000Z |
| 919108f7-52d1-4320-9bac-f847db4148a8 | Version 4; no embedded timestamp |
| 2ed6657d-e927-568b-95e1-2665a8aea6a2 | Version 5; DNS namespace with the name www.example.com |
| 00000000-0000-0000-0000-000000000000 | Nil UUID; a special all-zero value |
| ffffffff-ffff-ffff-ffff-ffffffffffff | Max UUID; a special all-one value |
Try the first value in the UUID timestamp decoder. The UTC result should match the table; local time depends on your timezone. A random v4 UUID should produce no timestamp, not today's date.
Check the v7 timestamp in JavaScript
const value = "017f22e2-79b0-7cc3-98c4-dc0c0c07398f";
const hex = value.replaceAll("-", "");
const milliseconds = Number.parseInt(hex.slice(0, 12), 16);
console.assert(milliseconds === 1645557742000);
console.assert(new Date(milliseconds).toISOString() === "2022-02-22T19:22:22.000Z");This is a field-extraction example for an already-known v7 fixture. Validate the version and variant before applying it to untrusted input. The first 48 bits fit exactly in a JavaScript number; a complete 128-bit UUID does not. Use BigInt or bytes for the full value.
Reproduce a name-based UUID in Python
import uuid
expected = uuid.UUID("2ed6657d-e927-568b-95e1-2665a8aea6a2")
assert uuid.uuid5(uuid.NAMESPACE_DNS, "www.example.com") == expected
assert expected.version == 5
assert expected.variant == uuid.RFC_4122The namespace and exact name bytes matter. Case changes, Unicode normalization or a different namespace can produce a different result. A v5 hash is not encryption: an attacker can test candidate names when the namespace is known.
Check canonical byte order
import uuid
import base64
value = uuid.UUID("919108f7-52d1-4320-9bac-f847db4148a8")
assert len(value.bytes) == 16
assert value.bytes.hex() == "919108f752d143209bacf847db4148a8"
assert uuid.UUID(bytes=value.bytes) == value
encoded = base64.b64encode(value.bytes).decode("ascii")
assert uuid.UUID(bytes=base64.b64decode(encoded)) == value
print(encoded)Compare these bytes with the UUID binary and Base64 converter. They follow the left-to-right order of the canonical hexadecimal string. Python's bytes_le, Microsoft GUID binary layouts and MySQL UUID_TO_BIN with swap enabled are different conventions. Agree on one convention before transporting binary identifiers between systems.
Choose a generation API for your runtime
| Runtime | Random v4 | Time-based v7 |
|---|---|---|
| Modern browser on HTTPS or localhost | crypto.randomUUID() | Maintained library, such as uuid |
| Node.js 24 | node:crypto randomUUID() | uuid package v7() |
| Node.js 26.1+ | node:crypto randomUUID() | node:crypto randomUUIDv7() |
| Python 3.14+ | uuid.uuid4() | uuid.uuid7() |
| PostgreSQL 18+ | gen_random_uuid() | uuidv7() |
See the Node.js guide, Python guide and PostgreSQL guide for version-specific examples. Check your deployed runtime, not just your development machine. UUID storage support does not necessarily mean the runtime can generate every version.
Tests worth adding to your application
Reject malformed lengths and non-hexadecimal characters. Decide explicitly whether braces, URNs, uppercase text and Nil/Max are acceptable. Test a valid UUID of the wrong version when your endpoint requires v7. Check binary round trips without relying on JavaScript Number for the full 128-bit value.
Keep uniqueness constraints in the database. These fixtures verify parsing and representation; they do not establish collision resistance, access rights, or the truth of an encoded timestamp.
Sources and verification
The fixed fixture assertions are covered by FastUUID's automated tests. JavaScript and Python examples were checked locally; PostgreSQL availability is documented, not a claim that a PostgreSQL benchmark was run.
