How to decode a UUID
Every RFC 9562 UUID stores its version in the 13th hex digit and its variant in the top bits of the 17th digit:
xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
M = version (1-8) N = variant (8, 9, a, b = RFC 9562)
| Version digit | Meaning | Contains a timestamp? |
|---|---|---|
| 1 | Gregorian time-based | Yes (100 ns since 1582) |
| 2 | DCE Security | Partial |
| 3 | Name-based, MD5 | No |
| 4 | Random | No |
| 5 | Name-based, SHA-1 | No |
| 6 | Reordered Gregorian time | Yes (100 ns since 1582) |
| 7 | Unix Epoch time | Yes (ms since 1970) |
| 8 | Custom | Only if your format has one |
Variant digit
| Binary | Hex digit | Variant |
|---|---|---|
0xxx | 0 - 7 | Reserved, NCS backward compatibility |
10xx | 8 - b | RFC 9562 (the standard variant) |
110x | c - d | Reserved, Microsoft backward compatibility |
111x | e - f | Reserved for future definition |
The decoder never throws on odd input: unknown versions, legacy variants and the special nil (00000000-…) and max (ffffffff-…) UUIDs all produce a readable result.
Learn more in UUID versions explained.