TFT

UUID Regex Tester & Pattern Generator

Test and generate regular expressions for matching UUIDs. Get pre-built regex patterns for common formats (with hyphens, without, with braces) and validate your custom patterns against live UUID examples.

UUID Regex Tester

Test and validate UUIDs with regex patterns

How to use

Enter your data in the input field, click Convert, and the result will appear in the output field. You can then copy or download the result.

How it works

Enter UUID strings to validate them against standard UUID regex patterns. The tester checks format, version, and variant compliance according to RFC 4122.

The tool highlights valid UUIDs in green and invalid ones in red, showing exactly which part of the pattern failed. It supports UUIDs with or without hyphens, in upper or lowercase.

Pattern examples:

Standard format (with hyphens): xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Valid UUIDs: 550e8400-e29b-41d4-a716-446655440000 ✓ 6ba7b810-9dad-11d1-80b4-00c04fd430c8 ✓ Invalid UUIDs: 550e8400e29b41d4a716446655440000 (no hyphens) 550e8400-e29b-41d4-a716-44665544000g (invalid char 'g') 550e8400-e29b-41d4-a716 (too short)

The regex validates the 8-4-4-4-12 hexadecimal pattern. It also checks that version (bits 12-15 of time_hi_and_version) and variant (bits 64-65 of clock_seq) are valid.

When You'd Actually Use This

Form input validation

Users paste UUIDs into web forms. Client-side regex validation catches typos before submission. Show immediate feedback: "Invalid UUID format" vs "UUID not found in database".

Data import cleanup

Importing CSV files with UUID columns? Validate each entry before database insertion. Flag invalid UUIDs for manual review instead of letting bad data corrupt your tables.

API request validation

REST APIs often use UUIDs in URLs: /api/users/550e8400-e29b-41d4-a716-446655440000. Validate the UUID format before querying the database to prevent injection attacks.

Log file parsing

Extract UUIDs from log files using regex. Validate extracted strings to ensure you're capturing actual UUIDs, not random hex strings that happen to be 32 characters.

Database migration verification

After migrating UUID columns, run validation to ensure all values are properly formatted. Catch truncation or encoding issues before they cause application errors.

Testing and QA

Generate test data with valid and invalid UUIDs. Verify your application handles both correctly. The regex tester helps create comprehensive test cases.

What to Know Before Using

Standard UUID format includes hyphens.The canonical representation is 8-4-4-4-12 hex digits with hyphens: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. Some systems store without hyphens for compactness.

Case doesn't matter for UUIDs.550E8400-E29B-41D4-A716-446655440000 and 550e8400-e29b-41d4-a716-446655440000 are identical. The regex accepts both uppercase and lowercase hex digits.

Version and variant bits have constraints.Version (bits 12-15 of third group) must be 1-5. Variant (bits 64-65 of fourth group) must be 10xx (8, 9, a, or b in hex). Strict regex enforces these.

Regex validates format, not authenticity.A valid-format UUID might not exist in your system. Regex confirms the string looks like a UUID, not that it's a real, assigned identifier.

Pro tip: For database storage, consider storing UUIDs without hyphens (32 chars) to save space. Add hyphens only for display using formatting functions.

Common Questions

What's the regex pattern for UUID validation?

Basic: /^[0-9a-f]8-[0-9a-f]4-[0-9a-f]4-[0-9a-f]4-[0-9a-f]12$/i. Strict (with version/variant): /^[0-9a-f]8-[0-9a-f]4-[1-5][0-9a-f]3-[89ab][0-9a-f]3-[0-9a-f]12$/i

Can UUIDs have uppercase letters?

Yes, both uppercase and lowercase are valid. The RFC 4122 standard specifies lowercase for canonical form, but parsers should accept both. The regex uses case-insensitive matching.

What are the valid UUID versions?

Version 1 (time-based), 2 (DCE security), 3 (MD5 hash), 4 (random), and 5 (SHA-1 hash). Versions 1, 3, 4, and 5 are commonly used. Version 2 is rare.

How do I validate UUIDs in JavaScript?

Use the test() method: const uuidRegex = /^[0-9a-f]8-...$/i; uuidRegex.test(inputString). Returns true for valid format, false otherwise.

What's a nil UUID?

The nil UUID is all zeros: 00000000-0000-0000-0000-000000000000. It's a valid format but represents a null or uninitialized value. Some systems use it as a sentinel.

Can I use UUID regex for GUID validation?

Yes, GUIDs (Microsoft's implementation) use the same format as UUIDs. The terms are often used interchangeably. The same regex validates both.

What if my UUIDs don't have hyphens?

Use a regex without hyphens: /^[0-9a-f]32$/i. Or add hyphens programmatically: insert '-' at positions 8, 12, 16, and 20 in the 32-character string.