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.
Page Contents
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
| Version | How it is made | Use today? |
|---|---|---|
| v1 | Timestamp + device MAC address | Rarely – can reveal the device |
| v3 / v5 | Hash of a name (MD5 / SHA-1) | When the same input must always give the same ID |
| v4 | 122 random bits | Yes – the most common |
| v7 | Unix timestamp in milliseconds + random bits | Yes – 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 | |
|---|---|---|
| Size | 4–8 bytes | 16 bytes |
| Created offline or on the client | No | Yes |
| Merging data from several databases | Conflicts | No conflicts |
| Reveals how many records exist | Yes | No |
| Readable | Yes | No |
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.
Need a website or app for your business? Talk to Techpass Master – we design and build websites and apps for clients worldwide.
