UUID v7 Generator

Generate time-ordered RFC 9562 version 7 UUIDs from a Unix millisecond timestamp and random bits.

Description

Generate RFC 9562 UUID version 7 identifiers with a 48-bit Unix millisecond timestamp and random trailing bits.

UUID v7 places Unix time in milliseconds at the beginning of a 128-bit UUID, so lexicographic byte order broadly follows creation time. The remaining payload provides uniqueness while the version and variant retain the standard UUID layout.1

When to use UUID v7 Generator

Use UUID v7 for database keys, event IDs, and logs where globally generated identifiers should also have useful time ordering. Leave timestamp blank for the current time; supply it and a seed only for deterministic test fixtures.

How UUID v7 Generator works

The most significant 48 bits store milliseconds since the Unix epoch. The generator sets the version nibble to 7 and RFC variant bits to 10, then fills the remaining 74 bits with pseudorandom data and formats the result canonically.1

How the UUID version 7 generation function processes input

  1. Write the Unix millisecond timestamp to bytes 0 through 5 in big-endian order.
  2. Fill the remaining fields with pseudorandom bits.
  3. Set the version nibble to 0111 and the variant bits to 10.
  4. Format the bytes into the standard five hexadecimal groups.

Limitations and assumptions

  • The timestamp exposes approximate creation time and is not a trusted timestamp.
  • This implementation does not add a monotonic counter, so identifiers generated within one millisecond rely on random bits rather than strict ordering.
  • A fixed seed is for reproducibility and should not be used where unpredictability is expected.

Alternative or Complementary approaches

Use UUID v4 when timestamp disclosure and ordering are unnecessary. Parse a UUID to inspect its version or validate external text before storing it.

References

  1. RFC 9562: Universally Unique IDentifiers (UUIDs) — RFC Editor

Similar or alternative tools

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies