UUID regex
Thirty-two hex digits in 8-4-4-4-12 groups, with a version digit from 1 to 8 and the RFC 9562 variant bits (8, 9, a or b). Copy the pattern, with 4 inputs it accepts and 5 it rejects, each checked against it at build time.
Part of developer tools.
^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iFlags: i
What the uuid regex accepts and rejects
Each result below is the output of the pattern itself, run on the input when this page was built — not a claim copied next to it. A wrong verdict stops the build.
| Input | Result | Why |
|---|---|---|
| 123e4567-e89b-12d3-a456-426614174000 | Passes | version 1, time-based |
| 550e8400-e29b-41d4-a716-446655440000 | Passes | version 4, random |
| 01890a5d-ac96-774b-bcce-b302099a8057 | Passes | version 7, time-ordered |
| F47AC10B-58CC-4372-A567-0E02B2C3D479 | Passes | upper case, thanks to the i flag |
| 00000000-0000-0000-0000-000000000000 | Fails | the nil UUID has version 0 |
| 550e8400e29b41d4a716446655440000 | Fails | no hyphens |
| 550e8400-e29b-41d4-c716-446655440000 | Fails | variant c is not the RFC variant |
| {550e8400-e29b-41d4-a716-446655440000} | Fails | braces, as Windows writes GUIDs |
| 550e8400-e29b-41d4-a716-44665544000g | Fails | g is not a hex digit |
Limits
- The nil UUID (all zeros) and the max UUID (all f) are valid values in RFC 9562 but carry no version, so they are refused. Accept them explicitly if your data uses them as sentinels.
- Braced and hyphen-less forms are refused. Strip braces and normalise the case before storing, rather than widening the pattern.
Try it on your own input
Open this pattern in the regex tester with every example above on its own line. The link adds the g and m flags so that ^ and $ hold per line and every line is tested: the highlighted lines are the ones marked as passing here. Paste your own data in place of the examples — it is matched in your browser and never uploaded.
Other common regexes
- Email address
- URL
- IPv4 address
- Hex color
- ISO 8601 date
- 24-hour time
- Semantic version
- URL slug
- Phone number (E.164)
- US ZIP code
- MAC address
Or open the regex tester empty and bring your own pattern.