The UUID Regex Java Validator is designed to help developers ensure their UUIDs (Universally Unique Identifiers) are formatted correctly in Java applications. From backend services to distributed systems and databases, UUIDs are essential for uniquely identifying entities without collision.
Looking for more Java-based validation tools? Try:
[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 a UUID?
A UUID (or GUID) is a 128-bit number used to uniquely identify data. It is represented as a 36-character string with five sections separated by hyphens:
xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
M indicates the UUID version (1–5)
N indicates the variant (usually 8, 9, A, or B in hex)
UUIDs are heavily used in APIs, databases, distributed systems, and resource tagging to avoid collisions across systems.
Java Regex Pattern for UUID
Pattern Explanation:
[0-9a-fA-F]{8}: First group (8 hex digits)
[0-9a-fA-F]{4}: Second group (4 hex digits)
[1-5][0-9a-fA-F]{3}: Third group (Version 1–5 UUID)
[89abAB][0-9a-fA-F]{3}: Fourth group (Variant)
[0-9a-fA-F]{12}: Final group (12 hex digits)
Java Code Example
Valid & Invalid UUIDs
Valid:
123e4567-e89b-12d3-a456-426614174000
550e8400-e29b-41d4-a716-446655440000
Invalid:
123e4567e89b12d3a456426614174000 (missing hyphens)
zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz (invalid characters)
123e4567-e89b-62d3-a456-426614174000 (invalid version: 6)
Common Use Cases
Database Keys: Use UUIDs as non-sequential primary keys for privacy.
Distributed Systems: Avoid key collisions across microservices or clusters.
API Resources: Identify and secure RESTful endpoints.
User IDs: Generate anonymous and unique identifiers for users.
Pro Tips
Use UUID version 4 (randomly generated) for security and simplicity.
Validate UUID format on both frontend and backend to prevent malformed input.
Normalize UUIDs by converting to lowercase before comparing or storing.
If you expect only certain versions (e.g., v4), refine the regex to match only those.
Store UUIDs as VARCHAR(36) in SQL databases to preserve formatting.
Regex checks format, not uniqueness — use a UUID library for generation.
Combine with These Tools
UUID Regex Java Validator: Cross-check format in Go-based systems.
Java Regex Tester: Modify or test variations of UUID formats.
Token Generator: Generate secure random tokens.
Base64 Encoder: Encode your UUID into Base64 for transmission.