The three formats and their layouts
A UUID is 128 bits, written as 32 hex digits in five groups: 8-4-4-4-12. The version number sits in the first digit of the third group, and the variant is the first digit of the fourth, always 8, 9, a or b.
- v4 comes from the browser's
crypto.randomUUID(). Six bits are fixed for version and variant, so 122 bits are random. Because that function needs a secure context, it works on HTTPS pages and localhost only. - v7 (RFC 9562, published in 2024) is assembled here by hand. The first 48 bits are the current Unix time in milliseconds, followed by the version, then 74 random bits from
crypto.getRandomValues. - NanoID draws characters from a 64-symbol URL-safe alphabet, using the low six bits of each random byte. Every character therefore carries exactly 6 bits, so the default 21 characters hold 126 bits, comparable to a v4 UUID in a shorter string.
Worked example: reading the v7 timestamp
The millisecond clock reading 1700000000000, which is 14 November 2023, 22:13:20 UTC, is 018bcfe56800 in hex. Any v7 UUID made at that instant therefore starts with 018bcfe5-6800-7. Ids made a second later start with a slightly larger prefix, so sorting them as text sorts them by creation time. A v4 id has no such structure.
| Format | Length | Sorts by time | Best for |
|---|---|---|---|
| UUID v4 | 36 chars | No | General identifiers, tokens you never index in order |
| UUID v7 | 36 chars | Yes, to the millisecond | Database primary keys |
| NanoID | 2 to 64 chars (21 default) | No | Short public ids in URLs |
Details and limits
- You can create 1 to 500 ids at once. Values outside that range are clamped, and "Copy all" copies the list one per line.
- The Uppercase and No dashes options affect UUIDs only. NanoID ignores them and has its own length setting.
- Two v7 ids made within the same millisecond share a timestamp and differ only in their random bits, so their relative order is not guaranteed. A batch of 500 will mostly share a few prefixes.
- Random v4 keys scatter inserts across a database index, which is the reason v7 exists. Time-ordered keys append near the end of the index instead.
- A UUID is an identifier, not a secret. For passwords or API keys, use the password generator, and for placeholder records see the mock data generator.