HomeRegex LibraryUUID v4 Identifier Validation Regex
100% Client-Side β€’ 0 B Data Leaves Browser
validation

UUID v4 Identifier Validation Regex

Validates 36-character canonical random UUID version 4 format.

Regular Expression Pattern:
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
Valid Match Example:
f47ac10b-58cc-4372-a567-0e02b2c3d479
Invalid / Non-Match Example:
invalid-uuid-string

Regex Syntax Breakdown & Explanation

  • β€’^[0-9a-f]{8} : 8 hex digits
  • β€’-[0-9a-f]{4} : 4 hex digits
  • β€’-4[0-9a-f]{3} : Version 4 prefix with 3 hex digits
  • β€’-[89ab][0-9a-f]{3} : Variant bits (8, 9, a, or b)
  • β€’-[0-9a-f]{12}$ : 12 hex digits node identifier

Implementation in Popular Languages

JavaScript / TypeScript
const regex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
const isValid = regex.test("f47ac10b-58cc-4372-a567-0e02b2c3d479");
console.log(isValid); // true
Python (re)
import re

pattern = r"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
match = re.match(pattern, "f47ac10b-58cc-4372-a567-0e02b2c3d479")
print(bool(match)) # True
Go (regexp)
package main
import (
  "fmt"
  "regexp"
)

func main() {
  re := regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$`)
  fmt.Println(re.MatchString("f47ac10b-58cc-4372-a567-0e02b2c3d479"))
}
Frequently Asked Questions

Frequently Asked Questions

Everything you need to know regarding specifications, syntax, and security best practices.

The regular expression pattern is /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i. Validates 36-character canonical random UUID version 4 format.