UUID V4 — What Developers Need to Know
UUID v4 is the go-to for database primary keys, session tokens, file names, and any scenario requiring a unique identifier without a central counter.
What is UUID V4?
Version 4 UUIDs are randomly generated — 122 bits of randomness, formatted as xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx. The 4 at position 13 and the variant bits at position 17 are the only fixed nibbles. Collision probability is astronomically low.
UUID vs GUID — same thing?
Yes. GUID (Globally Unique Identifier) is Microsoft's name for UUID. Both follow the same RFC 4122 standard. SQL Server uses UNIQUEIDENTIFIER internally and formats GUIDs with braces: {xxxxxxxx-...}.
No-dash format use cases
Removing dashes gives you a compact 32-char hex string — useful for URL slugs, filenames, Redis keys, and any system where - has special meaning. It's still a valid UUID, just without formatting.
Are these cryptographically secure?
Yes — this tool uses crypto.randomUUID() (or crypto.getRandomValues() fallback), which pulls from the OS CSPRNG, the same source as openssl rand. Never server-generated, never logged.
When to use UUID as a DB primary key
UUIDs prevent ID enumeration attacks, work across distributed systems without coordination, and let you generate IDs client-side before the DB insert. Downside: larger index size vs INT. Use BINARY(16) in MySQL for compact storage.
URN format
The URN format prefixes with urn:uuid: per RFC 4122. Used in XML schemas, SAML assertions, certain API specs, and anywhere a fully qualified namespace is required to avoid ambiguity between ID types.