Skip to content
TPToolPocket
← Back to Blog

What is a UUID and When Should You Use One?

·5 min read

If you've worked with databases, APIs, or distributed systems, you've probably seen strings like this:

550e8400-e29b-41d4-a716-446655440000

That's a UUID (Universally Unique Identifier) — a 128-bit label designed to be unique across all computers, all time, without any central coordination.

UUID Structure

A UUID is 32 hexadecimal characters displayed in 5 groups:

xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
│             │    │
│             │    └── Variant (8, 9, a, or b)
│             └─────── Version (4 = random)
└───────────────────── 128 bits of data

UUID Versions

  • v1— Based on timestamp + MAC address. Unique but leaks the generating machine's identity.
  • v4Random. The most common version. 122 bits of randomness. This is what you almost always want.
  • v5 — Deterministic hash from a namespace + name. Same input always produces the same UUID.
  • v7 — Newest. Timestamp-ordered + random. Sorts chronologically, great for database primary keys.

UUID v4: How Random is Random?

UUID v4 uses 122 random bits. That gives 2^122 ≈ 5.3 × 10^36 possible values. To put that in perspective:

  • You'd need to generate 2.71 quintillion UUIDs before having a 50% chance of a single collision
  • If you generated 1 billion UUIDs per second, it would take 86 years to reach that threshold
  • The probability of a collision with 10 million UUIDs is about 1 in 10^22 — essentially zero

UUID vs Auto-Increment IDs

UUIDAuto-Increment
UniquenessGlobally uniqueOnly within one table
SecurityUnpredictableSequential (easy to guess)
Storage16 bytes4-8 bytes
Index perfWorse (random order)Better (sequential)
DistributedNo coordination neededRequires central authority

When to Use UUIDs

  • Public-facing IDs— Don't expose sequential IDs in URLs (/users/3 leaks that you have 3 users)
  • Distributed systems — Multiple servers creating records without a shared counter
  • Merge scenarios — Importing data from multiple databases without ID conflicts
  • Client-generated IDs — Create the ID before sending to the server (optimistic UI)

GUID vs UUID

They're the same thing. GUID(Globally Unique Identifier) is Microsoft's name for it. UUID is the standard (RFC 4122) name. Same format, same algorithms, different branding.

Generate UUIDs Now

Need UUIDs? Our UUID Generator creates cryptographically secure v4 UUIDs in bulk using crypto.randomUUID(). Generate up to 100 at a time, copy individually or all at once.