How to generate UUIDs
- 1.
Pick a version
v4 is fully random and the most widely used. v7 starts with a timestamp, so the IDs sort chronologically.
- 2.
Set the count and format
Generate 1 to 1000 UUIDs, optionally uppercase, without hyphens or wrapped in braces like a Windows GUID.
- 3.
Copy or download
Copy a single UUID, copy all of them, or download a .txt file with one UUID per line.
- 4.
Validate a UUID
Paste any UUID into the validator to check its format and see the version, variant and, for v1, v6 and v7, the timestamp.
What a UUID is
A UUID (Universally Unique Identifier, called a GUID in the Microsoft world) is a 128-bit number written as 32 hexadecimal digits in groups of 8-4-4-4-12, e.g. 017f22e2-79b0-7cc3-98c4-dc0c0c07398f. The format is defined by RFC 9562 (May 2024), which replaced RFC 4122.
- The 13th character is the version (here
7). - The 17th character is the variant - for standard UUIDs it is always
8,9,aorb(bits10).
The special Nil UUID (all zeros) and Max UUID (all F) are recognised by the validator too.
UUID v4 or v7?
| UUID v4 | UUID v7 | |
|---|---|---|
| Contents | 122 random bits | 48-bit Unix time (ms) + 74 random bits |
| Sort order | random | chronological |
| Database index (B-tree) | fragmentation, slower inserts | appends at the end - fast |
| Reveals creation time | no | yes (to the millisecond) |
| Best for | tokens, public identifiers | primary keys, logs, events |
In this generator, UUID v7 values keep their order even when many are created within the same millisecond: the 12-bit rand_a field works as a counter (method 1 from RFC 9562, section 6.2).
Can a UUID ever repeat?
In theory yes, in practice no. UUID v4 has 2122 ≈ 5.3 × 1036 possible values. For a 50% chance of even one collision you would need about 2.7 × 1018 identifiers - generating a billion UUIDs per second, that would take around 85 years. The condition is a good source of randomness: this tool uses crypto.randomUUID() and crypto.getRandomValues(), never Math.random().
UUIDs in databases and code
- PostgreSQL - the
uuidtype takes 16 bytes;gen_random_uuid()generates v4 without extensions since version 13, anduuidv7()is built in since version 18. - MySQL / MariaDB - store UUIDs as
BINARY(16)instead ofCHAR(36)to save 20 bytes per row and in every index. - JavaScript -
crypto.randomUUID()returns v4; v7 needs a library or a small custom function. - Python -
uuid.uuid4();uuid.uuid7()is available since Python 3.14. - SQL Server -
uniqueidentifiersorts bytes in an unusual order, so the benefit of v7 there is smaller.
The hyphenated form is 36 characters long, without hyphens 32. The braces option gives the format used in the Windows registry and Visual Studio project files.
Frequently asked questions
What is the difference between a UUID and a GUID?
+
Is a UUID v4 safe to use as a secret token?
+
How do I read the date from a UUID v7?
+
How should I store UUIDs in a database?
+
Should I use UUID v7 for primary keys?
+
Are the UUIDs sent anywhere?
+
Updated: