UUID Explained: Versions, Uses and When to Use One
Last updated: 23 July 2026 · 5 min read
A UUID (Universally Unique Identifier), also called a GUID, is a 128-bit value written as 36 characters: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. The whole point is that anyone, anywhere, can generate one without coordinating with a central server and be practically certain it will never clash with anyone else’s.
Why collisions basically never happen
A random (v4) UUID has 122 random bits — about 5.3×10³⁶ possibilities. You would need to generate billions of UUIDs per second for many years before the chance of a single collision became meaningful. For all practical purposes, they are unique.
The versions you’ll meet
- v4 (random) — the most common. Generated from random data. Use this unless you have a specific reason not to.
- v1 (time-based) — built from a timestamp and machine identifier. Sortable by creation time, but can leak the MAC address and time.
- v7 (time-ordered) — a newer version combining a timestamp with randomness, so IDs sort roughly by creation time while staying private. Great for database keys.
When to use a UUID
- Distributed systems where multiple services create records independently.
- Public identifiers where you do not want to expose how many records exist (unlike an auto-increment
1, 2, 3…). - Offline-first apps that must create IDs before syncing to a server.
UUID vs auto-increment vs NanoID
An auto-increment integer is compact and fast but reveals record counts and needs a central database. A UUID is decentralized and opaque but long. A NanoID gives you the same practical uniqueness in far fewer, URL-safe characters — handy for links and filenames. Choose UUID for standards compatibility, NanoID when size and URL-friendliness matter.
Generate one instantly
You can create v4 UUIDs with the free UUID Generator, or shorter IDs with the NanoID Generator — both run entirely in your browser using secure randomness.
