UUID format
xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
The M digit shows the version (4 or 7), and the first digit of N is 8, 9, a or b for the standard variant. Everything else is random (v4) or a timestamp followed by random bits (v7).
Version 4 vs version 7
| | v4 | v7 |
| Contents | 122 random bits | 48-bit millisecond timestamp + 74 random bits |
| Sort order | Random | By creation time |
| Best for | General IDs, tokens in URLs | Database keys, logs, events |
| Reveals time? | No | Yes (to the millisecond) |
Generating UUIDs in code
- JavaScript: crypto.randomUUID()
- Python: uuid.uuid4()
- PostgreSQL: gen_random_uuid()
- C#: Guid.NewGuid()
Need random numbers or passwords instead? Use the random number generator or the password generator.
Last reviewed October 2026.
Frequently asked questions
What is a UUID?
A UUID (universally unique identifier), also called a GUID, is a 128-bit ID written as 32 hexadecimal characters in five groups, like 3f2b8c1e-9d4a-4c7e-8b21-5a6f0e9d1c34. They can be created independently on any computer with practically no chance of two matching.
Should I use version 4 or version 7?
Version 4 is fully random and the most widely used. Version 7, standardized in RFC 9562 (2024), starts with a timestamp, so IDs sort in creation order. That makes v7 a great choice for database primary keys because it keeps indexes efficient.
Can two UUIDs ever be the same?
In theory, yes; in practice, no. A version 4 UUID has 122 random bits. You would need to generate about a billion UUIDs every second for roughly 85 years to have a 50% chance of a single duplicate.
Are these UUIDs secure?
They are generated with your browser's cryptographically secure random number generator. Still, UUIDs are identifiers, not secrets: do not use them alone as passwords or access tokens.
What is the difference between a UUID and a GUID?
Nothing meaningful. GUID is Microsoft's name for the same 128-bit identifier format.