What Is a UUID? UUID v4 vs v7 Explained (and When to Use Each)

A UUID (Universally Unique Identifier) is a 128-bit ID like 3f2b8c1e-9a4d-4c7b-8e21-5d6f0a1b2c3d. Any system can create one on its own – without asking a database or a central server – and be practically certain nobody else will ever create the same one. That makes UUIDs perfect for distributed systems, mobile apps and APIs.

Free tool
Generate UUIDs
Create random UUID v4 or time-ordered UUID v7, up to 1,000 at once, in the format you need – and validate or decode any UUID. Free.
Open UUID Generator →

The format

A UUID is written as 32 hexadecimal characters in five groups: 8-4-4-4-12. The first character of the third group shows the version (4 or 7), and the first character of the fourth group shows the variant.

Versions you will meet

VersionHow it is madeUse today?
v1Timestamp + device MAC addressRarely – can reveal the device
v3 / v5Hash of a name (MD5 / SHA-1)When the same input must always give the same ID
v4122 random bitsYes – the most common
v7Unix timestamp in milliseconds + random bitsYes – best for database keys

UUID v7 was standardised in RFC 9562 in 2024.

v4 vs v7

  • v4 is completely random. Simple and private, but random keys spread inserts across a database index, which can slow large tables.
  • v7 starts with a timestamp, so new IDs sort in creation order. Databases insert them efficiently, and you can see roughly when a record was created. Our UUID Generator decodes that timestamp for you.

Can two UUIDs be the same?

In theory, yes. In practice, no. With 122 random bits, you would need to generate around 2.7 quintillion v4 UUIDs to have a 50% chance of a single duplicate. Use a cryptographically secure random generator (as our tool and modern libraries do), and duplicates are not a real-world concern.

UUID or auto-increment ID?

Auto-increment (1, 2, 3…)UUID
Size4–8 bytes16 bytes
Created offline or on the clientNoYes
Merging data from several databasesConflictsNo conflicts
Reveals how many records existYesNo
ReadableYesNo

Many apps use an internal integer key and a UUID for public URLs and APIs.

Generating UUIDs in code

  • JavaScript (browsers and Node.js): crypto.randomUUID() – v4
  • Kotlin / Java: UUID.randomUUID() – v4
  • Python: uuid.uuid4(); newer versions also offer v7
  • PostgreSQL: gen_random_uuid() – v4

UUID or GUID?

GUID is Microsoft’s name for the same thing. They are interchangeable.

FAQ

What is a UUID used for?

Unique IDs for database records, files, API requests, devices and sessions – without a central counter.

Are UUIDs secure?

v4 and v7 are hard to guess, but they are identifiers, not secrets. Do not use them as passwords or tokens.

Which UUID version should I use?

v7 for database keys; v4 for general random IDs.

Are UUIDs case-sensitive?

No. Lowercase is the standard way to write them.

Is a GUID the same as a UUID?

Yes – GUID is Microsoft’s name for a UUID.

Free tool
Try the free UUID Generator
No signup and nothing uploaded – it runs right in your browser. Browse all 74 free tools on our Free Tools page.
Open UUID Generator →

Need a website or app for your business? Talk to Techpass Master – we design and build websites and apps for clients worldwide.

WhatsApp us📞 Call now