Dev Hub Solutions

Product studio

Get in touch

UUID v4 regex

Strict UUID v4 pattern. Validates the 8-4-4-4-12 hex layout, version nibble `4` in position 14, and variant nibble (`8`, `9`, `a`, or `b`) in position 19. Case-insensitive flag accepts both lower and uppercase hex.

The pattern

/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
Open in tester

Caveats

Specifically validates v4 — v7 IDs have version nibble `7` and would need a different pattern. To accept any UUID version: replace `4[0-9a-f]{3}` with `[1-7][0-9a-f]{3}` and `[89ab]` with `[0-9a-f]`.

Test strings

A mix of values that should match and values that shouldn't — paste these into the tester to see them light up live.

  • 9e0c2a4b-8d3f-4b6e-9c1a-1f2b3c4d5e6f
  • 0193a0b8-3e7e-7c91-9d2a-5f6a7b8c9d0e
  • 550e8400-e29b-41d4-a716-446655440000
  • not-a-uuid
  • 00000000-0000-0000-0000-000000000000