UUID v4 vs v7: Structure, Timestamps and Bulk Generation

Last updated: · 4 min read

Database rows, message queues and distributed services often need identifiers created independently, without a central counter. A UUID (Universally Unique Identifier) is a 128-bit value written as 36 characters, and it is the standard way to create such identifiers. This guide covers the two most used versions: v4, which is fully random, and v7, which is defined in RFC 9562, carries a Unix timestamp and sorts in time order. It also explains how the bulk generator makes between 1 and 100 values at once, and how the format options change the text. The example uses the real output of the Bulk UUID Generator.

Formula

UUID: 128 bits, written as 8-4-4-4-12 hexadecimal digits (32 digits plus 4 hyphens)

v4 (random):
  bits 0–47 and 64–127: random (122 bits)
  version (digit 13) = 4
  variant (top bits of digit 17) = 10

v7 (time-based):
  bits 0–47: Unix time in milliseconds (48 bits)
  version (digit 13) = 7
  bits 52–63: random or counter (12 bits)
  variant = 10; the remaining 62 bits are random

Format: upper or lower case and with or without hyphens (for example 01a1f796-de40-…)

The layout comes from RFC 9562 (2024), which replaces RFC 4122. In v4 every bit except the version and variant bits is random. The first 48 bits of v7 keep values in time order, so they index far more efficiently in a database than v4. Two v7 values created in the same millisecond are ordered by their random bits, so strict ordering within one millisecond needs a monotonic counter.

What the inputs mean

Version
v4 (random) or v7 (timestamp-based, RFC 9562). For a primary key in a new table, v7 gives better index performance.
Count
The number of UUIDs to generate at once, a whole number from 1 to 100.
Letter case
Lowercase (the default) or uppercase. Most systems use lowercase; older systems sometimes show uppercase.
Dashes
With dashes (8-4-4-4-12) or without, giving a 32-character string. The version without dashes is shorter in URLs and file names.

Worked example: Two v7 UUIDs and their timestamp

  1. Input: Version v7, Count 2, Lowercase, Dashes on. Output: 01a1f796-de40-72f6-8efc-da286246a27f and 01a1f796-de40-72f7-8b63-986fdd529e54.
  2. The first 12 hexadecimal digits of both are 01a1f796de40. Converted to decimal, this is 1795155222080.
  3. 1795155222080 milliseconds is 2026-11-20 06:13:42.080 UTC, and both values were created in that same millisecond.
  4. Digit 13 is 7 in both (the 72f6 and 72f7 groups), and digit 17 is 8, 9, a or b (8efc and 8b63), which is the variant 10 pattern.
  5. The order of the two values (72f6 before 72f7) comes from their random bits, so a time-based order is not guaranteed inside one millisecond.

Result: Each output is a 36-character UUID. The first 48 bits carry the time, so values created over time form an increasing sequence.

🆔 Bulk UUID / GUID Generator

Free, no sign-up; your data stays in your browser.

Open the calculator →

How to read the result

v4 is strong for privacy but scatters index entries; v7 sorts by time, so new rows append at the end of a database index. Because v7 carries a timestamp, it reveals when the value was created; use v4 where the creation time must stay hidden. Do not use a UUID alone as a secret key or session token.

Common mistakes

  • Using a UUID as a secret. Even when a UUID is hard to guess, it is not an authentication token; use a cryptographically secure token generator.
  • Mixing up v4 and v7. The version is digit 13: 4 means v4 and 7 means v7.
  • Comparing values stored with and without dashes. The same UUID appears as two different strings in the two forms.
  • Mixing letter cases. Both cases are valid, but one system should use one case consistently.
  • Expecting strict order from v7. Within the same millisecond the order is not guaranteed; store the creation time separately if you need an exact sequence.

Frequently asked questions

Is a UUID the same as a GUID?

Yes. GUID is the name Microsoft uses for the same 128-bit format defined by RFC 4122 and RFC 9562.

What is the chance of two UUIDs colliding?

A v4 UUID has 122 random bits, so collisions are extremely unlikely in practice. It is still not a guarantee, so critical systems should also enforce a uniqueness constraint.

Why is v7 better in a database?

Its values increase with time, so B-tree indexes add new rows at the end; v4 values land in random positions and fragment the index.

Does the tool store the UUIDs it makes?

The generation runs in your browser and the page does not send the values to a server. Still, be careful when pasting generated values into third-party pages.

The result is not exact or binding and is for information only; it is not an official document and cannot be used in official procedures. Confirm it with the competent authority or a professional before acting; no liability is accepted for losses arising from its use.

Sources

Choose your cookie preference to continue

Records the site needs to work (theme, language, favourites) stay in your browser.

This site is free and funded by ads.

With your consent, Google Analytics cookies measure visits and Google AdSense cookies are used to show ads; the data is processed on Google servers abroad.

If you reject, the site works just the same.

Cookie Policy · KVKK notice