Regex guide
UUID Regex Examples
UUID validation is common in APIs, databases, logs and configuration files. This guide provides practical UUID regex examples you can test and adapt.
Suggested pattern
^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
What it matches
550e8400-e29b-41d4-a716-446655440000
A987FBC9-4BED-3078-CF07-9141BA07C9F3
Common limitations
- Does not check the UUID version.
- Accepts uppercase and lowercase hexadecimal characters.
Suggested pattern
^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$
What it matches
550e8400-e29b-41d4-a716-446655440000
Common limitations
- Only validates the UUID v4 format.
- Does not verify that the value was generated randomly.
Suggested 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}$
What it matches
550e8400-e29b-41d4-a716-446655440000
6ba7b810-9dad-11d1-80b4-00c04fd430c8
Common limitations
- Checks the version digit only.
- Does not validate how the UUID was generated.
Suggested pattern
^[0-9a-fA-F]{32}$
What it matches
550e8400e29b41d4a716446655440000
Common limitations
- Does not check UUID version or variant.
- May also match any 32-character hexadecimal identifier.
What is a UUID?
A UUID is a universally unique identifier commonly used to identify records, users, sessions, objects and resources.
UUIDs are often found in databases, APIs, logs, configuration files and distributed systems.
Common UUID format
The most recognizable UUID format uses 32 hexadecimal characters separated into five groups: 8-4-4-4-12.
A standard UUID looks like 550e8400-e29b-41d4-a716-446655440000.
UUID versions
UUIDs can have different versions, such as v1, v3, v4 and v5.
A regex can check the version digit, but it cannot verify the generation method or uniqueness of the identifier.
Can regex verify UUID uniqueness?
A regex can validate the format of a UUID, but it cannot prove that the UUID is truly unique.
Uniqueness must be guaranteed by the generation algorithm, database constraints or application logic.
When to use a UUID regex
UUID regex patterns are useful for validating API parameters, database IDs, log entries, import files and configuration values.
They provide a quick first layer of validation before deeper application-specific checks.