How to Validate a UUID Format and Version

Check UUID/GUID strings against RFC 4122 layout, detect versions 1–7, batch-validate IDs, and know when to generate new UUIDs instead.

By Generatr Team

A UUID (Universally Unique Identifier) is a 128-bit value usually written as 32 hex digits in five hyphenated groups. Validation asks two separate questions: does the string match the expected shape, and do the version/variant bits claim a known layout under RFC 4122 (and related updates for newer versions)?

This guide covers format rules, versions 1–7, batch checking, timestamps on time-based versions, and when you should generate a fresh ID instead of “fixing” a bad one. Run strings through the free UUID validator — version detection, variant checks, and batch mode in the browser.

To mint new random IDs, use the UUID generator and the UUID generation guide. Microsoft-style GUIDs follow the same 128-bit idea — see the GUID guide.

Free tool

Use the UUID Validator now

Open the interactive uuid validator in your browser — free, instant, no signup.

Open UUID Validator

What Makes a UUID String Valid?

The common textual form is:

xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx

  • 32 hex digits (0–9, a–f or A–F) plus 4 hyphens in fixed positions (8-4-4-4-12)
  • M — the version nibble (1–7 in current practice for standard layouts)
  • N — the start of the variant field; RFC 4122 variant uses binary 10xx, so the hex digit is typically 8, 9, a, or b

Acceptable variants of the string

  • With or without hyphens (32 continuous hex chars) — many APIs accept both; always know which your system stores
  • Uppercase or lowercase hex — usually treated as equal
  • Optional braces in some Microsoft contexts: {…}

Invalid examples: wrong group lengths, non-hex characters, only 31 digits, or a “UUID-looking” random string with an illegal version nibble for your policy.

Paste candidates into the free UUID validator before writing custom regex that drifts from the RFC fields. Regex that only checks “36 characters with hyphens” will accept strings whose version nibble is 0 or whose variant bits are wrong — fine for a rough filter, insufficient as your only gate.

Prefer a library or explicit field checks in production code. Use the browser validator when you are triaging a bad ID from a ticket, a log line, or a spreadsheet column and need an answer in seconds.

What Do RFC 4122 and UUID Versions Mean?

RFC 4122 defined the classic layout and versions widely deployed in software. Later work (including RFC 9562 updates in the UUID space) documents additional versions such as v6 and v7 that keep the 128-bit size while improving time ordering.

The version is encoded in the high nibble of the third group. The variant marks which bit layout family you are in. Validators that only check “hex + hyphens” miss both fields.

Versions you will actually see

  • v1 — time-based with node (often MAC-derived historically); sortable by time with caveats
  • v3 / v5 — name-based (MD5 / SHA-1 hash of a namespace + name); deterministic for the same inputs
  • v4 — random (most common for new public IDs)
  • v6 / v7 — time-ordered designs that play nicer with database indexes than pure random v4
  • v2 — DCE security variant; rare in web apps

A string can be format-valid as “UUID-shaped” yet fail a product rule that only allows v4. Policy is separate from syntax. For how random v4 IDs are minted, read the how UUIDs work guide.

How Do You Detect UUID Version and Variant?

Read the structure; do not guess from the first characters alone.

  1. Normalize: strip braces/hyphens if needed; lowercase for comparison.
  2. Confirm 32 hex digits.
  3. Version = nibble at the version position (character index 12 in the continuous hex form, 0-based).
  4. Variant = top bits of the next field (continuous index 16). RFC 4122 variant expects the pattern that maps to hex 8–b for the first digit of that group.

Timestamps on time-based versions

v1, v6, and v7 embed time information you can extract for debugging “when was this ID created?” — with the usual caveats about clock skew and generator quality. v4 has no meaningful timestamp in the bits; any “created at” must come from your database column.

The UUID validator surfaces version, variant, and timestamp extraction where applicable so you do not decode fields by hand during an incident.

Name-based v3/v5 tie into hashing of a namespace and name — different problem from validating an existing ID. For general digests, see the hash generator guide.

When Should You Batch-Validate UUIDs?

One bad ID in a migration file or CSV import can fail thousands of rows. Batch mode is for bulk lists, not for replacing database constraints.

  • Import pipelines — reject or quarantine rows before insert
  • API contract tests — fixture files full of resource IDs
  • Log forensics — separate well-formed correlation IDs from garbage tokens
  • Migration audits — count how many stored values are v4 vs other versions

What to record per line

Pass/fail, version, variant, and a short reason (bad length, bad hex, wrong version nibble, wrong variant). That report is more useful than a single boolean for a 10,000-line file.

UUIDs often travel inside JSON bodies. Pretty-print and schema-check payloads with the JSON formatter validator and its JSON validation guide when the failure might be structural JSON rather than the UUID field itself.

Run multi-line input through the free UUID validator batch path, then fix generators upstream so bad IDs stop appearing.

Should You Validate an Existing UUID or Generate a New One?

These are different jobs.

  • Validate when an ID already exists — path params, foreign keys, webhook payloads, user-supplied references. You accept or reject; you do not invent a substitute silently.
  • Generate when you create a new resource and need a fresh primary key or correlation ID.

Do not “repair” invalid UUIDs

Padding digits, swapping characters, or forcing a version nibble destroys referential integrity. If the client sent garbage, return 400 with a clear error. If a legacy row is corrupt, fix data with a controlled migration, not ad-hoc string surgery in the request path.

Security note

Validation is not authentication. A well-formed v4 UUID is still a secret only if you treat it as one (unguessable capability URLs). Predictable or leaked IDs need authorization checks, not prettier regex.

Mint new values with the UUID generator or GUID generator; check old values with the UUID validator.

In API design, document whether path parameters must be hyphenated v4 strings, whether you accept uppercase, and whether the NIL UUID is rejected. Clients that pass validation locally but fail in production almost always disagree on one of those three rules.

What Common UUID Validation Failures Should You Expect?

Most production failures are boring and mechanical.

  • Truncation — copy/paste cut the last group
  • Extra whitespace or newlines — trim before parse
  • Wrong separators — underscores or spaces instead of hyphens
  • Non-hex characters — letter G, punctuation, or full-width digits
  • NIL UUID confusion00000000-0000-0000-0000-000000000000 is format-valid in many parsers but forbidden by some business rules
  • Version policy mismatch — string is fine, app only accepts v4
  • Binary vs string mix-ups — 16 raw bytes vs 36-char text; endianness issues in some GUID byte layouts

Log the failure class. “invalid_hex” and “unsupported_version” lead to different fixes (client bug vs generator config).

When IDs are embedded in larger documents, validate JSON first with the JSON formatter guide, then field-level UUID checks.

How Do You Use Generatr’s UUID Validator?

Single string or list — same idea.

  1. Open the free UUID validator.
  2. Paste one UUID or a batch of IDs (one per line when using batch mode).
  3. Review pass/fail and any normalize options (hyphens, case).
  4. Read detected version (1–7) and variant when the layout matches.
  5. For v1/v6/v7, inspect extracted timestamps if shown.
  6. Export or note failures for import cleanup.
  7. If you need a replacement ID for a new row, generate separately — do not edit the invalid string.
  8. Add the same checks in server code so the browser tool is a debug aid, not the only gate.

Related tools: UUID generator, GUID generator, hash generator for digests, and JSON formatter validator for payloads that carry IDs.

Step-by-Step Instructions

  1. 1Open the free UUID validator on Generatr.
  2. 2Paste a candidate UUID or GUID string (with or without hyphens as your source provides).
  3. 3Confirm the tool reports a valid 128-bit hex layout and legal group structure.
  4. 4Read the detected version nibble (1–7) and variant bits.
  5. 5If the version is time-based, review any extracted timestamp for debugging.
  6. 6For many IDs, use batch mode and collect per-line pass/fail reasons.
  7. 7Reject or quarantine invalid values in your import or API layer — do not silently rewrite them.
  8. 8Generate a brand-new UUID only when creating a new resource, not when validating an old reference.

Frequently Asked Questions

What is a valid UUID format?+

Typically 32 hexadecimal digits in 8-4-4-4-12 groups separated by hyphens, with a version nibble in the third group and RFC-style variant bits in the fourth. Many systems also accept 32 hex digits with no hyphens.

How do I know if a UUID is version 4?+

After confirming hex layout, check the version nibble (the first character of the third group in the hyphenated form). For v4 it is 4. Also check that the variant digit is 8, 9, a, or b for the common RFC variant.

Is a UUID the same as a GUID?+

GUID is Microsoft’s name for the same 128-bit identifier idea. String forms are usually interchangeable for web APIs; some binary GUID layouts differ in endianness for certain fields.

Can I fix an invalid UUID by changing one character?+

No. Changing digits creates a different ID and breaks references. Return an error for bad input, or generate a new UUID only when you are creating a new entity.

Why validate UUIDs in batch?+

Imports, fixtures, and log extracts often contain thousands of IDs. Batch validation finds format and version problems before they hit the database or scatter through production logs.

Is Generatr’s UUID validator free?+

Yes. Validate format and version (including batch checks) in your browser without an account. Use it alongside server-side validation in real systems.

Ready to try it yourself?

Use the free UUID Validator — no download, no account.

Launch UUID Validator