← Back to all regex patterns
Validation
Low backtracking risk

Regex for UUID v4

UUID v4 patterns help validate request IDs, webhook event IDs, and client-generated identifiers without accepting the wrong version bit.

Regex
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i

Try this pattern

Matches current input
550e8400-e29b-41d4-a716-446655440000

1 match found in the current text.

Passing examples

  • 550e8400-e29b-41d4-a716-446655440000
  • 987fbc97-4bed-4078-8f07-9141ba07c9f3

Failing examples

  • 550e8400-e29b-11d4-a716-446655440000
  • not-a-uuid

Code examples

JavaScript
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;
regex.test(input);
Python
import re
pattern = re.compile(r"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$", re.IGNORECASE)
bool(pattern.search(input))
Go
re := regexp.MustCompile("(?i)^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$")
matched := re.MatchString(input)

Related Validation Patterns