UUID Regex Python Validator
Search...
⌘K
UUID Regex Python Validator
Search...
⌘K


UUID Regex Python Validator
UUID Regex Python Validator
Validate UUID strings with the UUID Regex Python Validator built for Python developers working on secure APIs, databases, and distributed systems. This tool checks whether your identifiers conform to the standard UUID format using Python regex. For full validation suites, pair it with the Email Regex Python Validator or IP Address Regex Python Validator to strengthen your backend input checks.
[A-Z]
: uppercase letters[a-z]
: lowercase letters[0-9]
: digits\.
: a literal dot+
: one or more of the preceding*
: zero or more of the preceding?
: optional (zero or one)^
: start of string$
: end of string
Test your APIs today!
Write in plain English — Qodex turns it into secure, ready-to-run tests.
Regular Expression - Documentation
What is UUID Regex?
A UUID (Universally Unique Identifier) is a 128-bit identifier used to uniquely label data across systems. It’s typically represented as 32 hexadecimal characters split into 5 groups by hyphens, like:
123e4567-e89b-12d3-a456-426614174000
UUIDs are used in databases, APIs, microservices, IoT, and any context requiring global uniqueness.
UUID Regex Pattern in Python
To match a standard UUID format (v1–v5), use this regex pattern:
^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$
This pattern checks:
8 hexadecimal characters
4-digit version group (starting with 1–5)
4-digit variant group (starting with 8–b)
Final 12 hex digits
How to Validate UUIDs Using Regex in Python
Here’s how to use the re module in Python to match valid UUIDs:
import re def is_valid_uuid(uuid_str): pattern = re.compile(r'^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$') return bool(pattern.match(uuid_str)) # Example test uuids = [ "123e4567-e89b-12d3-a456-426614174000", # Valid "123e4567e89b12d3a456426614174000", # Invalid (no hyphens) "ZZZe4567-e89b-12d3-a456-426614174000" # Invalid (non-hex) ] for u in uuids: print(f"{u} -> {is_valid_uuid(u)}")
Matching UUIDs Without Hyphens
If you need to match UUIDs where hyphens have been removed—sometimes encountered in compact database keys or legacy systems—you can simply adjust the regex pattern. Instead of including hyphens as separators, look for a continuous string of 32 hexadecimal characters.
Here's how you can modify the pattern:
^[0-9a-fA-F]
This pattern matches UUIDs written as a single, uninterrupted 32-character hexadecimal string (e.g., 123e4567e89b12d3a456426614174000
). It’s useful when handling non-standard formats or cleaning up user input before validation.
Be sure to pick the pattern that matches your data’s format—hyphenated or plain—depending on your application’s needs.
Use Cases
API Resource Identification: Use UUIDs in REST endpoints or JSON payloads to reference records uniquely.
Database Indexing: Use UUIDs as primary keys to prevent collision across distributed tables.
Session Management: Validate UUID-based tokens for user sessions in secure applications.
Form Submissions: Check if hidden fields in forms pass valid UUIDs.
Combine with Password Regex Python Validator to secure user login data.
Pro Tips
UUIDs can be lowercase or uppercase, and this pattern matches both.
Use Python’s uuid module to generate and compare UUIDs, and validate format with this regex.
This regex only checks the format, not the UUID’s randomness or version logic.
Normalize UUIDs to lowercase using .lower() before storage for consistency.
Combine with the Email Regex Python Validator or Phone Number Regex Python Validator for full form validation in Python apps.
Frequently asked questions
Discover, Test, and Secure your APIs — 10x Faster.

Product
All Rights Reserved.
Copyright © 2025 Qodex
Discover, Test, and Secure your APIs — 10x Faster.

Product
All Rights Reserved.
Copyright © 2025 Qodex