Skip to content
SimpleTools24

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.

Find the Version Digit

text
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.

Version digit meanings
DigitVersionContains
1v1Gregorian timestamp, clock sequence, node
2v2DCE security
3v3MD5 name-based hash
4v4Random
5v5SHA-1 name-based hash
6v6Reordered Gregorian timestamp, node
7v7Unix millisecond timestamp, random
8v8Custom layout
0, 9–fnoneNot a defined version (or the nil/max UUID)

UUID versions explained describes what each version is for.

Check the Variant Digit

Variant digit meanings
17th digitVariant
0–7NCS (reserved, legacy)
8, 9, a, bRFC 9562 standard
c, dMicrosoft (reserved, legacy)
e, fReserved 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 group 11d0, version 1; fourth group a765, 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 is uuid5(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

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'); // 4

Or use version() from the uuid npm package.

Python

python
import uuid
u = uuid.UUID('9b2c1f7e-5d3a-4c8b-a1e2-7f6d0c9b3a54')
u.version   # 4
u.variant   # 'specified in RFC 4122'

PostgreSQL 17+

sql
SELECT uuid_extract_version('9b2c1f7e-5d3a-4c8b-a1e2-7f6d0c9b3a54'::uuid); -- 4

Regex

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.

Sources