Skip to content
ToolDesk

What Is a UUID? How v4 Works and When to Use It

Updated 2026-07-28

A UUID (Universally Unique Identifier) is a 128-bit identifier designed to be unique across the world. It is widely used for database primary keys, file names, and API request IDs — anywhere you need an ID that will not collide. This guide focuses on v4, the most common variant, and explains how it works and when to use it.

The UUID format

A UUID is written as hexadecimal in five hyphen-separated groups of 8-4-4-4-12 (e.g. 123e4567-e89b-42d3-a456-556642440000). That is 32 hex digits, or 128 bits. A few of those bits are fixed to indicate the version and variant.

v4 is essentially random

A v4 UUID sets 122 bits at random (the rest indicate version and variant). With good randomness (cryptographic randomness), the chance of a collision at realistic generation volumes is negligible. Our UUID generator uses the browser’s crypto.randomUUID() to produce cryptographically secure v4 UUIDs.

Versus sequential IDs

  • Sequential IDs (1, 2, 3…) are short and readable but require coordinated allocation and collide easily in distributed systems
  • UUIDs can be generated independently anywhere without coordination — great for distributed or offline generation
  • UUIDs are long and do not leak counts or ordering the way sequential IDs can
  • On the downside, UUIDs are long and make URLs and logs harder to read

When to use it and caveats

UUIDs suit scenarios where multiple servers or clients issue IDs independently, or where you want hard-to-guess IDs. Note that v4 is random, so it has no meaningful order, which can be less efficient for database indexes than sequential IDs (time-ordered variants exist to address this). A UUID is a random identifier, not a secret — do not use it in place of an authentication token.

To generate them, our UUID generator is handy — you can create several at once, entirely in your browser. For matching or fingerprinting data, the hash generator helps too.