Validate UUIDs instantly with the UUID Regex Go Validator from Qodex. Whether you’re assigning user IDs or referencing resources, this tool ensures UUIDs are in the correct format. You can pair it with our API Key Generator, Username Generator, or Address Generator to build full mock datasets for testing and development.
[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?
In Go, validating strings that must follow a UUID (Universally Unique Identifier) format is common in backend systems, APIs, and database records. UUIDs ensure that every entry has a globally unique ID—especially important when systems scale or operate across multiple servers.
UUIDs are typically formatted like this:
x: Any hexadecimal digit
M: UUID version (1–5)
N: Variant (8, 9, a, or b)
A regex for validating UUIDs helps ensure that:
The input is the right length
The segments are correctly formatted
The UUID version and variant are valid
UUID Regex Pattern in Go
To validate UUIDs in Go using regex, you can use:
This pattern checks for:
8 hex digits
4 hex digits
A version digit (1–5)
A variant digit (8, 9, a, b)
12 final hex digits
How to Validate UUIDs in Go
Here’s a working Go example:
Use Cases
Assigning IDs in distributed databases
Identifying API users or sessions
Ensuring uniqueness in system logs or tokens
Referencing files, messages, or records across systems
Pro Tips for UUID Validation
UUIDs can be uppercase or lowercase—this regex supports both.
Version 4 UUIDs are most common for random generation. You can customize the pattern to only match v4 by replacing [1-5] with 4.
Always validate UUIDs before storing them in the database to prevent garbage data.
Avoid using UUIDs for user-facing identifiers unless you format or mask them properly—they can be long and hard to read.
Use Go’s regexp.MustCompile() instead of Compile() for static patterns—it’s faster and cleaner for runtime.
Combine with These Tools
Create full mock data flows by combining this validator with:
API Key Generator: Assign secure access credentials alongside UUIDs.
Phone Number Generator: Build realistic user profiles.
Email Generator: Add email IDs to simulated user data.
Username Generator: Complete fake profiles with randomized usernames.
Address Generator: Pair UUIDs with user address data for testing.