Text check
UUID validator
The checker accepts canonical hexadecimal UUIDs and reports the version nibble and variant. A stricter pattern below also requires version 1–8 and the RFC variant.
Validate UUIDs
Paste one or more UUIDs to check the text, version, and variant.
| Line | Value | Result | Version | Variant |
|---|
The structural pattern checks the 8-4-4-4-12 groups only. The versioned pattern also checks that the version nibble is 1–8 and the variant nibble is 8, 9, a, or b. The version 7 pattern is the same idea with the version fixed at 7.
In the canonical string, the version character is at index 14. That is the first character of the third group.
Structural pattern
^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
Versioned pattern
^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$
UUID v7 pattern
^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-7[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$
JavaScript
const UUID_VERSIONED = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/;
function uuidVersion(value) {
if (!UUID_VERSIONED.test(value)) return null;
return Number.parseInt(value.charAt(14), 16);
}
Python
import re
UUID_VERSIONED = re.compile(
r"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
)
def uuid_version(value: str) -> int | None:
if UUID_VERSIONED.fullmatch(value) is None:
return None
return int(value[14], 16)
Questions
What counts as valid here?
The checker accepts 32 hexadecimal digits, with the standard hyphens or without them. A leading urn:uuid: is ignored. It then shows the version nibble and the variant bits.
Which pattern is the strict one?
The versioned regular expression also requires version 1 through 8 and a variant nibble of 8, 9, a, or b. The nil UUID does not match that stricter pattern.
Do the code samples call a library?
No. The JavaScript and Python samples only test the versioned regular expression and read the version character.