What a UUID is
A UUID is a 128-bit identifier written as 32 hex digits in five groups — 8-4-4-4-12. One digit says which version it is, another which variant. Any machine can create one without asking a central server, and the chance of two being equal is small enough to ignore. Microsoft calls the same thing a GUID.
| Kind | Looks like | Sortable by time | Typical use |
|---|---|---|---|
| UUID v4 | 9b2f…-4… | No | The default: uuid.uuid4(), crypto.randomUUID(). |
| UUID v7 | 0199a…-7… | Yes, to the millisecond | Database primary keys (RFC 9562, 2024). |
| ULID | 01K6… | Yes, also as text | Sortable IDs in 26 readable characters. |
| Nano ID | V1StGXR8_Z5jdHi6B-myT | No | Short IDs in URLs and file names. |
For a new database table, prefer UUID v7: new keys land at the end of the index instead of on random pages, so inserts stay fast as the table grows. For a value that must stay secret — a reset link, an API key — use none of these: use a token generator such as Python's secrets.token_urlsafe().
How to use the UUID generator
- Pick the type: UUID v4, UUID v7, ULID or Nano ID.
- Set How Many — up to 1,000 at once — and press Generate.
- For UUIDs, choose Uppercase, Hyphens or Braces (the GUID style); for Nano ID, the length and alphabet.
- Press Copy All or Download .txt. A bulk batch of v7 or ULID comes out in creation order.
- Switch to Inspect and paste any UUID or ULID to see its version, variant and the time it was made.
Examples
Fill a test table with ordered keys
A hundred UUID v7s, already sorted the way the database will sort them.
Read the time out of a UUID v7
The first 12 hex digits are a Unix time in milliseconds.
Check a UUID from an old system
A v1 UUID carries a timestamp and, often, the MAC address of the machine that made it.
Make short IDs for URLs
Ten-character Nano IDs from letters and digits.
UUIDs in your language
import uuid uuid.uuid4() # random uuid.uuid7() # time-ordered, Python 3.14+ # Not for secrets — use the secrets module instead import secrets secrets.token_urlsafe(32)
// Random v4, built into browsers and Node.js 19+ crypto.randomUUID() // v7 with the uuid package (version 10 or later) import { v7 as uuidv7 } from 'uuid'; uuidv7();
-- Random v4, built in since PostgreSQL 13 SELECT gen_random_uuid(); -- Time-ordered v7, PostgreSQL 18+ CREATE TABLE orders ( id uuid PRIMARY KEY DEFAULT uuidv7() );
Frequently asked questions
Can two UUIDs collide?
In theory, yes; in practice, no. A UUID v4 has 122 random bits: you would need to generate about 2.7 quintillion of them for an even chance of a single duplicate. UUID v7 adds a timestamp, so a clash would also need the same millisecond.
Are UUIDs secret?
No. A v4 is hard to guess but was never designed as a secret, and v1, v6 and v7 reveal when they were made — v1 often also the machine's MAC address. Never use a UUID as a password reset token or an API key.
Why use UUID v7 instead of v4 for primary keys?
Database indexes are sorted. Random v4 keys land on random index pages, so every insert touches a different page and the index fragments. v7 keys start with the time, so new rows go to the end of the index, the way an auto-increment ID does.
What is the difference between a UUID and a GUID?
Nothing important: GUID is Microsoft's name for the same 128-bit identifier. GUIDs are often written in uppercase and wrapped in braces, {…} — the Braces and Uppercase options produce that form.
Is a thousand at once guaranteed to be unique?
Yes, within the batch. UUID v7 and ULID go further: inside the same millisecond the random part counts up, as RFC 9562 and the ULID spec describe, so the batch is unique and stays in the order it was generated.