UUID Hyphen Converter
Convert single or bulk UUIDs between compact 32-character hex format and canonical 8-4-4-4-12 hyphenated strings.
Why Convert UUID Formats?
UUIDs (Universally Unique Identifiers) are 128-bit numerical labels defined by IETF specifications RFC 4122 and RFC 9562. While mathematical identity relies purely on the 16 bytes of binary data, practical storage and transport demand distinct text representations:
Standard Canonical Format
Represented as 36 characters with hyphens (e.g. 8-4-4-4-12). Ideal for logging, JSON APIs, and PostgreSQL UUID column types.
Compact 32-Character Hex
Hyphens stripped away. Ideal for MySQL BINARY(16) conversions, URL path parameters, and compact cache keys.
100% Client-Side Privacy
All string manipulation happens in browser memory. Sensitive customer IDs, user keys, and tokens are never transmitted to any external server.
The RFC 4122 and RFC 9562 Canonical Layout
The canonical representation separates 32 hexadecimal digits into 5 hyphen-delimited segments formatted as 8-4-4-4-12:
xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
| | | | | | | | | |
time_low | | | | node (48-bit)
time_mid | clock_seq_hi / variant (N)
time_hi / version (M) In modern UUID variants such as UUID v4 (pseudo-random) and UUID v7 (Unix Epoch time-ordered), these hyphen positions are retained strictly for backward compatibility with parsers expecting the 36-character format.
Storage Efficiency Across Databases
Choosing whether to store UUIDs as hyphenated strings, compact hex, or raw bytes has dramatic impacts on B-Tree index performance and disk consumption:
| Storage Type | Format Example | Bytes per Row | Index Overhead | Database Best Practice |
|---|---|---|---|---|
| Canonical String | 123e4567-e89b-12d3... | 36 bytes (+1-4 length byte) | High (poor cache locality) | PostgreSQL (auto-packed to 16B) |
| Compact String | 123e4567e89b12d3... | 32 bytes (+1-4 length byte) | Moderate (11.1% smaller than canonical) | Legacy databases without native UUID |
| Binary Byte Array | \x12\x3e\x45\x67... | 16 bytes fixed | Minimal (optimal) | MySQL BINARY(16), SQLite BLOB |
Programmatic Code Snippets
To perform these conversions in your application backend without external libraries:
Node.js / TypeScript
// Remove hyphens (canonical to compact)
const compact = uuid.replace(/-/g, '');
// Add hyphens (compact to canonical)
const canonical = compact.replace(/^([0-9a-f]8)([0-9a-f]4)([0-9a-f]4)([0-9a-f]4)([0-9a-f]12)$/i, '$1-$2-$3-$4-$5'); Python
import uuid
# Parse any format and output compact or canonical
u = uuid.UUID("123e4567-e89b-12d3-a456-426614174000")
compact = u.hex # '123e4567e89b12d3a456426614174000'
canonical = str(u) # '123e4567-e89b-12d3-a456-426614174000'
binary = u.bytes # 16 raw bytes for database insert MySQL 8.0+
-- Insert as optimal BINARY(16) with time-ordered swapping
INSERT INTO users (id, name) VALUES (UUID_TO_BIN('123e4567-e89b-12d3-a456-426614174000', 1), 'Alice');
-- Retrieve as standard hyphenated string
SELECT BIN_TO_UUID(id, 1) AS id, name FROM users; Frequently Asked Questions
Why do canonical UUIDs have hyphens?
How much database storage does stripping hyphens save?
Are compact UUIDs without hyphens valid in APIs?
How do I convert between hyphenated and compact UUIDs in SQL?
Is it safe to paste confidential production UUIDs here?
About This Tool
Strips or adds hyphens across single or bulk UUIDs, one per line, auto-cleaning urn:uuid: prefixes
and {braces} before reformatting. Paste a mixed batch of canonical and compact IDs and each
line is parsed and converted independently.
It only reformats punctuation and casing on already-valid UUIDs; it doesn't generate new ones (see UUID Generator) and it doesn't validate RFC version/variant bits, only that the hex payload is exactly 32 characters.
Key Features
- Bulk, line-by-line: paste any number of UUIDs and each is parsed and converted on its own.
- Add or remove hyphens: swap between compact 32-char hex and canonical 8-4-4-4-12, including a direction-swap button.
- Casing control: Preserve, lowercase, or UPPERCASE output.
- Braces & URN affixes: optional
{wrap}orurn:uuid:prefix on output. - Input auto-cleanup: strips existing
urn:uuid:prefixes, braces, and non-hex characters before validating. - Per-line validation: flags exactly how many lines failed to parse as valid 32-character UUIDs.