Strict vs relaxed matching

The canonical form is 8-4-4-4-12 lowercase hexadecimal with hyphens. Many systems accept uppercase, unhyphenated 32-character strings, or braces around the value. A strict validator rejects those; the relaxed mode accepts them and reports the normalized form.

  • Hyphenated canonical: f47ac10b-58cc-4372-a567-0e02b2c3d479
  • Unhyphenated: f47ac10b58cc4372a5670e02b2c3d479
  • Braced: {f47ac10b-58cc-4372-a567-0e02b2c3d479}
  • Nil UUID: 00000000-0000-0000-0000-000000000000 (valid but special)
  • Max UUID: ffffffff-ffff-ffff-ffff-ffffffffffff (RFC 9562 special case)

Version and variant

The 13th hex digit is the version. Valid values are 1–8 under RFC 9562, though most real systems use 4 or 7. The 17th hex digit encodes the variant: 8, 9, a or b for RFC 4122, 0–7 for NCS compatibility, c or d for Microsoft, e or f for future use.

A string can match the UUID regex and still be nonsense: the variant nibble must be consistent with the claimed version. The validator reports mismatches instead of treating them as valid.

The regex people copy

regex
^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$

This regex matches versions 1–8 and RFC 4122 variants. It rejects the nil and max UUIDs in some stricter variants; add explicit exceptions if those values are legal in your domain.