Skip to main content
CheckTown
Generators

UUID Generator: Create Unique Identifiers for Any Project

Published 5 min read
In this article

What Is a UUID?

A UUID (Universally Unique Identifier) is a 128-bit identifier that is guaranteed to be unique across space and time without a central authority. UUIDs are formatted as 32 hexadecimal digits in 5 groups separated by hyphens: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

There are several UUID versions, each generated differently. Version 4 (random) is the most widely used — it generates 122 random bits, making collisions astronomically unlikely (you would need to generate 1 billion UUIDs per second for 85 years to have a 50% chance of a collision).

How UUID Generation Works

UUID v4 uses cryptographically secure random generation.

  • Random bits — 122 random bits are generated using CSPRNG
  • Version marking — bits 12-15 of the third group are set to 0100 to indicate version 4
  • Variant marking — bits 6-7 of the fourth group are set to 10 to indicate RFC 4122 variant

Try it free — no signup required

Generate UUIDs →

When To Use UUIDs

UUIDs are the preferred identifier type for distributed systems and databases.

  • Database primary keys — use UUID primary keys in distributed systems to avoid ID conflicts during merges
  • Session tokens — generate UUIDs for session identifiers and temporary tokens
  • File naming — use UUIDs to generate unique filenames for user uploads and generated assets

Frequently Asked Questions

What is the difference between UUID v1, v3, v4, and v5?

v1 is time-based and includes the MAC address, making it traceable. v3 and v5 are deterministic — they hash a namespace and name to produce the same UUID every time (v3 uses MD5, v5 uses SHA-1). v4 is random and the most commonly used for general-purpose unique IDs. v7 (emerging standard) combines timestamp and randomness for sortable UUIDs.

Should I use UUID or auto-increment integers for database primary keys?

Auto-increment integers are simpler and more storage-efficient. UUIDs are better for distributed systems, merging data from multiple sources, exposing IDs in URLs without leaking sequence information, and enabling client-side ID generation before database insertion. For single-server applications, auto-increment is often sufficient.

Are UUIDs truly unique?

UUID v4 has 2^122 possible values — about 5.3 × 10^36. The probability of generating two identical UUIDs is so small it is effectively zero for any practical application. The birthday paradox means you need roughly 2.71 quintillion UUIDs to have a 50% chance of a collision.

Related Tools