How to Tell Which Version a UUID Is
By SimpleTools24Published 3 min read
To tell which version a UUID is, look at the 13th hexadecimal digit, the first character of the third group. In 9b2c1f7e-5d3a-4c8b-a1e2-7f6d0c9b3a54, the third group is 4c8b, so it's version 4. Then check the 17th digit, the first character of the fourth group: 8, 9, a or b means the standard RFC 9562 variant, which is the only variant where the version digit has these standard meanings.
In this guide
Find the Version Digit
xxxxxxxx-xxxx-Vxxx-Nxxx-xxxxxxxxxxxx
^ ^
| N = variant digit (17th hex digit)
V = version digit (13th hex digit)Count hex digits, not characters: hyphens don't count. In the standard form, the version digit is the 15th character of the string.
| Digit | Version | Contains |
|---|---|---|
| 1 | v1 | Gregorian timestamp, clock sequence, node |
| 2 | v2 | DCE security |
| 3 | v3 | MD5 name-based hash |
| 4 | v4 | Random |
| 5 | v5 | SHA-1 name-based hash |
| 6 | v6 | Reordered Gregorian timestamp, node |
| 7 | v7 | Unix millisecond timestamp, random |
| 8 | v8 | Custom layout |
| 0, 9–f | none | Not a defined version (or the nil/max UUID) |
UUID versions explained describes what each version is for.
Check the Variant Digit
| 17th digit | Variant |
|---|---|
| 0–7 | NCS (reserved, legacy) |
| 8, 9, a, b | RFC 9562 standard |
| c, d | Microsoft (reserved, legacy) |
| e, f | Reserved for future use |
If the variant digit isn't 8–b, the version digit doesn't follow the standard meanings above. In practice, nearly all UUIDs use the standard variant.
Worked Examples
f81d4fae-7dec-11d0-a765-00a0c91e6bf6: third group11d0, version 1; fourth groupa765, standard variant. It contains a timestamp; see how to get the timestamp from a UUID.9b2c1f7e-5d3a-4c8b-a1e2-7f6d0c9b3a54:4c8b, version 4;a1e2, standard. Random, no timestamp.cfbff0d1-9375-5685-968c-48ce8b15ae17:5685, version 5;968c, standard. Name-based: this one isuuid5(NAMESPACE_DNS, "example.com").0192f0c1-6a4b-7c3d-9e2f-0a1b2c3d4e5f:7c3d, version 7;9e2f, standard. Time-ordered.00000000-0000-0000-0000-000000000000: the nil UUID, a special value with no version.
Checking the Version in Code
JavaScript
function uuidVersion(id) {
const hex = id.replace(/[{}-]/g, '').toLowerCase();
if (!/^[0-9a-f]{32}$/.test(hex)) return null;
return parseInt(hex[12], 16);
}
uuidVersion('9b2c1f7e-5d3a-4c8b-a1e2-7f6d0c9b3a54'); // 4Or use version() from the uuid npm package.
Python
import uuid
u = uuid.UUID('9b2c1f7e-5d3a-4c8b-a1e2-7f6d0c9b3a54')
u.version # 4
u.variant # 'specified in RFC 4122'PostgreSQL 17+
SELECT uuid_extract_version('9b2c1f7e-5d3a-4c8b-a1e2-7f6d0c9b3a54'::uuid); -- 4Regex
To accept only certain versions, check the version position in a pattern; UUID regex patterns has examples for "any standard version", v4-only and v7-only.
Why the Version Matters
- Privacy: v1 and v6 may contain a hardware address; v1, v6 and v7 reveal creation time.
- Sorting: v6 and v7 sort roughly by time; v1 and v4 don't.
- Determinism: v3 and v5 always produce the same ID for the same input.
- Validation: some systems only accept certain versions, which can break when a generator changes.
Decode It Instantly
The UUID decoder names the version and variant of any UUID you paste, shows the canonical form, and for v1, v6 and v7 reveals the embedded timestamp, plus clock sequence and node for v1 and v6. For many values at once, the UUID validator lists the version of each line.
Spotting Versions at a Glance
With practice, you can often guess the version without counting:
- Values that start with similar digits, created around the same time, are usually v7 (or v6): the shared prefix is the timestamp.
- Several IDs ending in the same 12 digits are often v1 from one machine: that's the node field.
- Completely different-looking values with a 4 in the version position are v4.
- The same input producing the same UUID in different systems points to v3 or v5.
Version Checks in Data Pipelines
If you receive UUIDs from partners or other teams, checking versions during import can catch problems early:
- A sudden change from v4 to v1 might mean a system started exposing hardware addresses.
- Unexpected v8 values mean someone is using a custom layout that you can't interpret.
- Values with no defined version (0 or 9–f in that position) may come from a buggy generator or aren't UUIDs at all.
Logging the version distribution of incoming IDs is a cheap way to notice these changes.
Frequently Asked Questions
Which digit tells you the UUID version?
The 13th hex digit, the first character of the third group.
Can a UUID have version 0?
Not as a defined version. The nil UUID is all zeros; other values with 0 there aren't standard UUIDs.
Does GUID versioning work the same way?
Yes. GUIDs are UUIDs, and Guid.NewGuid() produces version 4.
How do I know if a UUID contains a timestamp?
If its version is 1, 6 or 7, it does.
Summary
Read the 13th hex digit for the version and the 17th for the variant. With the standard variant, the version tells you whether the UUID is random, time-based or name-based.
Related tools
Sources
- RFC 9562 – Universally Unique IDentifiers (UUIDs), Sections 4.1 and 4.2 – IETF (opens in a new tab)
Related articles
- UUID Versions ExplainedWhat each UUID version contains, how it's generated, and which ones to use for new systems.
- UUID Format ExplainedThe 8-4-4-4-12 layout, where the version and variant live, and the text forms systems accept.
- Get the Timestamp From a UUIDReading the embedded time from v1, v6 and v7 UUIDs, with worked examples and code, and what that time does and doesn't prove.