Skip to content
100% in your browser. Nothing you paste is uploaded — all processing runs locally. Read more →

UUID formats

On this page
  1. The canonical form
  2. Uppercase
  3. Braced
  4. No hyphens
  5. Base64
  6. Base32 (Crockford)
  7. Integer
  8. Binary (16 bytes)
  9. URL-safe variants
  10. Conversion examples
    1. JavaScript
    2. PostgreSQL
    3. Python
  11. Try it

The same 128-bit value has half a dozen common textual encodings. Knowing which is which prevents the kind of bug where a regex matches in test and fails in prod.

The canonical form

550e8400-e29b-41d4-a716-446655440000

Lowercase hex, 36 characters total (32 hex + 4 hyphens), in 8-4-4-4-12 groups. This is what RFC 4122 calls the canonical textual representation. It’s what virtually every API, database, and log line should use.

Regex to match it:

^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$

(For case-insensitive, use [0-9a-fA-F] or apply the i flag.)

Uppercase

550E8400-E29B-41D4-A716-446655440000

Same value, different casing. RFC 4122 says output should be lowercase but parsers must accept both. In practice:

When normalizing, lowercase. When comparing, normalize first or use a case-insensitive comparison.

Braced

{550e8400-e29b-41d4-a716-446655440000}

The Microsoft GUID convention used in Windows registry, COM, and Guid.ToString("B") in .NET. Strip the braces before storing or comparing.

No hyphens

550e8400e29b41d4a716446655440000

32 hex characters with the hyphens removed. Used as a compact identifier in URLs (“simple” or “N” format in .NET: Guid.ToString("N")). Reduces length from 36 to 32 characters but loses the visual structure.

Be cautious — a 32-char hex string is also what you’d get from MD5 or a truncated SHA, so if you see one in the wild without context, it might not be a UUID at all.

Base64

VQ6EAOKbQdSnFkRmVUQAAA==

The 16 raw bytes of the UUID encoded as base64 — 24 characters with padding, 22 without. Used when you need a UUID in a URL-unfriendly context but want fewer characters than the canonical form.

Watch out: standard base64 uses + and /, which need URL-encoding. For URLs, use base64url (RFC 4648 §5), which uses - and _ and is safe to drop into query strings.

Standard base64:   VQ6EAOKbQdSnFkRmVUQAAA==
Base64url:         VQ6EAOKbQdSnFkRmVUQAAA

Base32 (Crockford)

AHHE810E9D1IT2EBE6APAA92AG

26 Crockford-base32 characters. Less common for plain UUIDs; more common for ULIDs (a related spec that’s natively base32).

Integer

113059749145936325402354257176981405696

The 128-bit value as a single decimal integer (often unsigned). Used by some systems internally; rarely seen in APIs. JavaScript can’t represent it as a Number — you need BigInt or a string.

Binary (16 bytes)

The raw 128 bits, no encoding. Used for storage in BINARY(16) columns and in binary protocols. Two layouts in the wild:

If you’re moving binary UUIDs across platforms, convert through the canonical hex string first.

URL-safe variants

For UUIDs in URL paths, the canonical hex form (with hyphens) is the most compatible — every URL parser handles it without escaping. If you need shorter URLs:

Conversion examples

JavaScript

const id = "550e8400-e29b-41d4-a716-446655440000";

// to no-hyphens
const compact = id.replace(/-/g, "");

// to bytes (Uint8Array)
const bytes = new Uint8Array(16);
const hex = compact;
for (let i = 0; i < 16; i++) bytes[i] = parseInt(hex.substr(i*2, 2), 16);

// to base64
const b64 = btoa(String.fromCharCode(...bytes));

// to base64url
const b64url = b64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");

PostgreSQL

-- canonical to bytea
SELECT decode(replace('550e8400-e29b-41d4-a716-446655440000', '-', ''), 'hex');

-- bytea back to UUID
SELECT encode(bytea_value, 'hex')::uuid;

Python

import uuid, base64
u = uuid.UUID("550e8400-e29b-41d4-a716-446655440000")
u.bytes              # b'U\x0e\x84\x00...'
u.hex                # '550e8400e29b41d4a716446655440000'
base64.urlsafe_b64encode(u.bytes).rstrip(b"=").decode()

Try it

The UUID generator on this site has a format dropdown that outputs the canonical, uppercase, braced, no-hyphens, and base64 forms directly.