Back to Utilities

UUID v4 Generator

Generate RFC 4122 version 4 UUIDs in batches with case and hyphen options.

Advertisement
Loading...

What this tool does

UUID (Universally Unique Identifier) version 4 is a 128-bit identifier generated from random numbers, formatted as 32 hexadecimal characters separated by hyphens in an 8-4-4-4-12 pattern. The probability of collision is astronomically low: you would need to generate about 2.71 quintillion UUIDs before expecting a single duplicate, making UUID v4 ideal for database primary keys, distributed system identifiers, and request IDs.

This tool generates RFC 4122 compliant version 4 UUIDs in your browser using the secure random number generator. Each UUID has 6 reserved bits: 4 for the version (4xxx) and 2 for the variant (8, 9, a, or b in the third group). You can generate single UUIDs or batches of up to 100, with options for case and hyphen formatting.

Usage Example

// Standard UUID v4
550e8400-e29b-41d4-a716-446655440000
       ^    ^
       |    variant (8/9/a/b)
       version (4)

// Generate in Node.js
import { randomUUID } from "node:crypto";
const id = randomUUID();
// "550e8400-e29b-41d4-a716-446655440000"

// In the browser
const id = crypto.randomUUID();
// Same output, no library needed

Common Edge Cases

  • UUIDs are not designed for use as security tokens. The random bits are predictable if an attacker can observe enough outputs from a weak source.
  • Storing UUIDs as strings in a database is 36 bytes per row; storing as binary (BINARY(16)) reduces this to 16 bytes plus a small performance gain on indexed lookups.
  • Sorting by UUID produces essentially random order. If you need chronological ordering, consider UUID v7 which embeds a timestamp prefix, or a sequential ID scheme.
  • Some legacy systems have problems with hyphens or mixed case in identifiers. Most modern systems handle both formats without issues.
  • The variant bits in positions 17-18 of the canonical form must be 8, 9, a, or b. UUIDs that do not have these bits are not RFC 4122 compliant.

FAQ

Can two UUIDs ever collide?
Yes, but with negligible probability. For 122 random bits, the chance of any collision among N UUIDs is roughly N² / 2^123. Even generating a billion UUIDs per second for 100 years gives a collision probability of about one in a billion.
Should I use UUID v4 or v7?
Use v4 when you do not need time ordering. Use v7 when you want sortable identifiers that preserve creation order and improve database index locality. v7 was standardized in RFC 9562 in 2024.
Is UUID v4 a good session token?
No. Use a cryptographically random token with at least 128 bits of entropy, ideally 256 bits for high-value sessions. UUID v4 has only 122 random bits and may be predictable from weak sources.
Advertisement