In this article
What a UUID is
A UUID (universally unique identifier), called a GUID in Microsoft systems, is a 128-bit number written as 32 hexadecimal characters in five groups: 3f2b8c1e-9a4d-4e7b-8c21-5d6f7a8b9c0d. Any computer can generate one independently, and the chance of two random UUIDs ever being the same is so small that it can be ignored in practice. That makes them ideal when IDs are created in many places: different servers, phones working offline, or several services writing to the same database.
Version 4: random
A v4 UUID is 122 bits of randomness plus a few fixed bits that mark the version. It reveals nothing about when or where it was created, which is good for privacy. Its weakness is order: new v4 IDs are scattered randomly. In databases that store rows in key order (such as the B-tree indexes used by PostgreSQL and MySQL’s InnoDB), inserting random keys means writing all over the index, which can slow down large tables.
Version 7: time-ordered
Standardised in RFC 9562 (2024), a v7 UUID starts with the current Unix time in milliseconds, followed by random bits. New IDs therefore sort after older ones, so database inserts land at the end of the index, much like auto-increment numbers, while still being unique across machines. You can even read the creation time from the first 12 hex digits.
Which one to choose
| Use | Choose |
|---|---|
| Primary keys in a database | v7 |
| Events, logs, messages you will sort by time | v7 |
| Public IDs where creation time should stay hidden | v4 |
| Test data, file names, random tokens in non-security roles | v4 or v7 |
How to generate UUIDs
- Open the UUID Generator.
- Choose v4 or v7.
- Set how many, up to 1,000 at once, and the format: lowercase with hyphens (standard), uppercase, without hyphens or in {braces}.
- Copy or download the list.
Generated v7 IDs are guaranteed to sort in creation order even when many are made within the same millisecond.
Storage tips
- Use a native UUID column type where available (PostgreSQL
uuid), 16 bytes instead of 36 characters. - Stick to one text format across systems; “ABC…” and “abc…” may not match in string comparisons.
- Keep auto-increment numbers if you have a single database and do not expose IDs publicly, they are smaller and simpler.
UUIDs are not secrets
A UUID identifies something; it does not protect it. Do not use UUIDs as passwords, API secrets or password-reset tokens on their own. For secrets, use the Password Generator or your framework’s secure token functions. To turn a v7 timestamp into a date, paste the milliseconds into the Timestamp Converter.
Frequently asked questions
What is a UUID?
A 128-bit identifier written as 36 characters, used to give records unique IDs.
What is the difference between UUID v4 and v7?
Version 4 is fully random. Version 7 starts with a timestamp, so new IDs sort in time order.
Why choose v7 for databases?
Time ordered IDs keep database indexes more efficient than random ones.
Can two UUIDs be the same?
In practice the chance is so small it can be ignored.
Are UUIDs secret?
No. Do not use them as passwords or security tokens.
What is UUID v7?
A UUID whose first 48 bits are the Unix time in milliseconds, followed by random bits. It was standardised in RFC 9562 in 2024.
Is UUID v7 unique enough?
Yes. Each millisecond still has about 74 random bits, so collisions are practically impossible.
Does UUID v7 leak information?
It shows roughly when the ID was created. If that matters, for example in public links, use v4.