UUID Regex Javascript Validator

Search...

⌘K

UUID Regex Javascript Validator

Search...

⌘K


UUID Regex Javascript Validator

UUID Regex Javascript Validator

Validate UUIDs in JavaScript with precision using our UUID Regex JavaScript Validator. Test standard UUID formats directly in your browser and ensure accuracy across APIs, databases, and frontend forms. For broader validation tasks, try the JavaScript Regex Tester, GUID Regex JavaScript Validator, or Credit Card Regex JavaScript Validator to build robust, regex-based validation workflows.

deadbeef-7331-4123-8123-ba5eba11babe
Possible security issues
This regex appears to be safe.
Explanation
  • [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
Match information
Match 1: "deadbeef-7331-4123-8123-ba5eba11babe" at index 0
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 JavaScript, UUIDs (Universally Unique Identifiers) are often used to uniquely identify objects, records, or resources across distributed systems. Validating the format of a UUID ensures your application is working with properly structured data.


UUIDs typically follow this format:

xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx


Where:

  • x is any hexadecimal digit

  • M indicates the UUID version (usually 1 to 5)

  • N indicates the UUID variant (typically 8, 9, A, or B)


UUID Regex Pattern


Here’s a standard regex pattern for validating UUIDs:


^[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 ensures the UUID:

  • Is 36 characters long

  • Contains hyphens in the correct positions

  • Matches version and variant formatting rules


JavaScript Example – UUID Validation


function isValidUUID(uuid) {
  const uuidRegex = /^[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 uuidRegex.test(uuid);
}

const uuid1 = "f47ac10b-58cc-4372-a567-0e02b2c3d479";
console.log(`Valid UUID? ${isValidUUID(uuid1)}`); // true

Use the JavaScript Regex Tester to tweak or build your own custom UUID regex variations.


Use Cases for UUID Validation

  • Database Entries: Ensuring that primary keys or unique identifiers are properly formatted.

  • API Responses: Validating UUIDs in tokens, headers, or payloads.

  • Form Inputs: Preventing malformed UUIDs in user or admin-submitted data.

  • Client-Side Checks: Lightweight validation before sending data to servers.


For related validation needs, explore the URL Regex JavaScript Validator for links or the IP Address Regex JavaScript Validator for network values.


Pro Tips for Using UUID Regex


  • Always validate on both frontend and backend for security and data consistency.

  • UUIDs are case-insensitive. The regex accepts both upper and lower case hex digits.

  • Combine UUID validation with tools like Numbers Regex JavaScript Validator or Credit Card Regex JavaScript Validator to build full form validation flows.

  • Be cautious of leading/trailing whitespaces — trim inputs before testing.

  • UUIDs are not just for databases! Use them in session IDs, event logs, or any unique reference scenario.


Combine With These Tools


Frequently asked questions

What is a UUID?×
A UUID is a 128-bit unique identifier used across systems to identify data or objects without collisions.
Can I use this regex for all UUID versions?+
Why validate UUIDs in JavaScript?+
Are UUIDs case-sensitive?+
Where is UUID validation commonly used?+