UUID generator: v1, v3, v4, v5, v7 and ULID explained
UUID generator with a per-version layout diagram: v1, v3, v4, v5, v7 and ULID. v7 is sortable, v4 is random, v3/v5 are deterministic. All in your browser.
A UUID (Universally Unique Identifier) is a 128-bit value. Its purpose: independent systems can mint IDs without coordinating and still avoid collisions in practice - no central sequence service, no shared registry. The various versions mix timestamp, randomness, and (historically) hardware bytes differently. The right choice depends on whether the ID needs to be sortable, deterministic, or just random. The generator below shows the layout per version live: which bytes are reserved for a timestamp, which for randomness, which for a node field - and which properties fall out of those choices. v7 next to v4 - the sortability demo at the bottom shows in two clicks why v7 wins in databases.
c9b4cc37-286f-4d17-b123-2019e48ee175 The result explained
Each UUID version reserves a different bit layout. Here's what the selected version allocates - and which properties fall out of that.
v4 - random
Current122 bits of crypto-random · 4-bit version · 2-bit variant
Default choice. Pure randomness, no state, no order.
v4 or v7? - sortability, live
Generate 10 each of v4 and v7 in shuffled order. Hit Sort - v7 sorts back into generation order, v4 stays scrambled.
- — 8cc21226-9cbe-4621-9623-e4c6f26ec08d
- — 0ec360d5-ec45-4b7f-a503-2f7e2173a79f
- — 6e265fb2-91f6-4eb8-a4e6-19515076ffc3
- — f6988286-e677-40bf-b34d-dd3f6b1b21ac
- — b734ede2-f764-42ea-a811-e7a2ad3e980d
- — 5951284e-bec1-4835-99a5-5d95fe63d48c
- — 231985b3-6946-49b9-9151-dda9453c3b9b
- — df4bb548-fa11-4831-98a4-5aba4da84597
- — 5c0de568-f744-475f-b45f-9ffc3e55c6c3
- — 00a76555-7fbe-48ae-9d6f-7cf59a574a82
- +262 ms 019e0010-7338-7f52-830c-788579ab3739
- +104 ms 019e0010-729a-7789-a887-a56adaabb2a9
- +327 ms 019e0010-7379-7b83-8f21-05765ad25db4
- +0 ms 019e0010-7232-7950-b6a0-73a56f114880
- +434 ms 019e0010-73e4-7ec6-8edd-ae7128b20fda
- +46 ms 019e0010-7260-703c-a27b-1717932442b1
- +210 ms 019e0010-7304-7fd6-8af5-af293dadc8a2
- +162 ms 019e0010-72d4-77ae-a4a2-9cef36e69474
- +367 ms 019e0010-73a1-7f3b-9495-d53231949daf
- +483 ms 019e0010-7415-7d91-9562-885ddde3e12c
The amber block highlights the 48-bit ms timestamp - present only in v7. Hit Sort and watch the +ms markers: v7 lines up strictly ascending, v4 jumps around. In databases this means v7 keeps index pages tight; v4 scatters writes.
Runs in your browser. No network call. No account.
Which UUID version do you actually need?
Three questions usually decide it:
- Do you need sortability? If the ID will be a database primary key, an event ID, or a URL-safe time axis - pick v7 (RFC 9562) or ULID. Both place a millisecond timestamp at the front, so a string sort matches insertion order down to the millisecond (within the same ms, the implementation's counter or random tail decides the rest).
- Do you need determinism? If the same input must always yield the same ID, pick v3 (MD5) or v5 (SHA-1). v5 is the cleaner choice.
- Otherwise: v4. Pure randomness from the browser's crypto APIs, no state, no device leak.
You almost never need v1 - unless a legacy system demands it. The last 6 bytes of a v1 UUID are a 48-bit node field; depending on the implementation, that's the host's MAC address. The library this generator uses draws random node values, but plenty of other v1 generators still embed the real MAC. Anyone forwarding v1 IDs from logs or foreign APIs should treat those last 6 bytes as potentially sensitive.
The 128-bit layout per version
Every card above shows the layout in coloured bands. The notable differences:
- v1 - time + node. Three timestamp runs (time_low, time_mid, time_hi), permuted. A clock_seq field protects against clock jumps. The last 6 bytes are the 48-bit node field - historically a MAC address, randomly generated here.
- v3 / v5 - hash. The output is the MD5 or SHA-1 hash of namespace + name. Version and variant bits are written into the hash; everything else is hash bytes.
- v4 - random. 122 bits of cryptographic random. 4 bits version, 2 bits variant - that's it.
- v7 - time + random. 48-bit ms timestamp at the front, then 74 bits for random data and/or a monotonic counter (RFC 9562 leaves the precise split open). Version and variant bits separate the two regions.
- ULID - Crockford-32. 48-bit ms timestamp + 80-bit random, rendered in 26 Crockford-base32 characters. No 0/O or I/L ambiguity.
| Version | Random bits | Sortable | Privacy concern | Status |
|---|---|---|---|---|
| v1 | ~61 (node + seq, random here) | half | node field may be MAC | Legacy |
| v3 | 0 (deterministic) | no | MD5 is old but stable | Legacy |
| v4 | 122 | no | none | Current |
| v5 | 0 (deterministic) | no | none | Current |
| v7 | 74 (random/counter) | yes | timestamp readable | Modern |
| ULID | 80 | yes | timestamp readable | Modern |
v4 or v7 - the sortability demo
The demo below draws 10 v4s and 10 v7s in shuffled order. Click "Sort alphabetically" - the left column (v4) lands at random positions, the right column (v7) sorts back into generation order. That's exactly what happens in a database when you use a UUID column as a primary and sort key:
- With v4, every new row inserts at a random position in the B-tree index. Pages fragment; I/O scatters.
- With v7, new rows almost always sit at the end of the sorted sequence. Index pages stay tight; I/O stays sequential.
In MySQL and Postgres benchmarks over the last few years, the difference on large tables is often a single-digit factor in v7's favour. ULID has the same behaviour - just in a different notation.
When are v3 and v5 the right choice?
When the ID should be derived from something stable: a URL, a DNS name, a path, a file's content. Same input → same ID, without ever asking a database.
v5(DNS namespace, "example.com") = cfbff0d1-9375-5685-968c-48ce8b15ae17 v5(DNS namespace, "example.com") = cfbff0d1-9375-5685-968c-48ce8b15ae17
The namespace itself is a UUID. RFC 9562 Section 6.6 (Table 3) defines four standard namespaces - DNS, URL, OID, X.500 - which the generator above offers as presets. You can also use your own UUID as a namespace, e.g. one per application, so the same name yields different IDs across applications.
Prefer v5 over v3 because SHA-1 is a more robust hash than MD5 - though no cryptographic security is at stake here; it's only about good bit distribution.
What about v6, v8 and Microsoft GUIDs?
- v6 is v1 with the timestamp bytes reordered - sortable like v7. Its node field carries the same MAC question as v1: depending on the implementation, it can contain the real address or a random value. Barely deployed; v7 wins in practice.
- v8 is RFC 9562's "custom" slot for proprietary layouts. If you need it, you know; if you don't, you don't.
- Microsoft GUIDs are UUIDs in a big-endian / little-endian mix. When passing IDs between .NET and the rest of the world, watch for swapped bytes in the first three fields.
Bulk generation: 1, 10, 100, 1000
The "How many?" switch above draws the chosen count in one go. The list copies as a JavaScript array, CSV, or JSON - handy for seed data, load tests, or just observing how the layout behaves over many entries. With v7 the leading ms timestamp advances by one millisecond per row (so the demo has a visible sortability trace); with v4 you can see the uniform distribution of the random.
FAQ
Which UUID version should I use?
Default to v4 for session IDs and anything not needing order. v7 for database primary keys and event IDs - the timestamp prefix makes v7 sortable. v3 / v5 only for deterministic IDs from names (prefer v5 over v3). v1 only in legacy systems - the node field can carry the MAC depending on the stack.
What is UUID v7 and why is it sortable?
v7 (RFC 9562, 2024) has a 48-bit ms timestamp at the front, followed by 74 bits for random data and/or a monotonic counter (split across the version and variant bits). Because the timestamp occupies the leading bytes, v7 UUIDs sort lexicographically by millisecond time; ordering within the same millisecond depends on the implementation.
Does a v1 UUID leak my MAC address?
It depends. The last 6 bytes are a 48-bit node field - historically the MAC, but commonly random depending on the implementation. If you forward UUIDs from unknown stacks, prefer v4 or v7.
What's the difference between UUID and ULID?
ULID is a popular non-RFC scheme: 26 Crockford-base32 characters, 48-bit ms timestamp + 80-bit random. Sortable like v7, URL-friendlier, and unambiguous about 0/O and I/L.