UUID Generator and Decoder: Version 4 and Version 7

Generate 1 to 20 UUIDs at a time, either random version 4 or time-ordered version 7 (the default), or paste a UUID to see its version, variant and embedded time.

Runs in your browser: your files and text are not uploaded. Free, no account needed.

Last updated: · Reviewed by the QuickTooly Team

Version 4 or version 7?

Both are 128-bit values written as 32 hex digits in the 8-4-4-4-12 pattern, defined in RFC 9562. The digit after the second hyphen is the version: a 4 or a 7.

  • v7 starts with a 48-bit Unix timestamp in milliseconds, so IDs made later sort after IDs made earlier. As a database primary key this keeps new rows at the end of the index instead of scattered through it. The catch: anyone who sees the ID can read when it was created.
  • v4 has 122 random bits and no time. Use it when the creation time should stay hidden, or when IDs must not reveal their order.

Neither version is a secret. A UUID in a URL is hard to guess, but it is not an access token; check permissions on the server as well.

Where the randomness comes from

The tool uses the open-source uuid package. Version 4 comes from the browser's crypto.randomUUID when available, otherwise from crypto.getRandomValues. Version 7 takes its random bits from crypto.getRandomValues. When several v7 IDs are made in the same millisecond, as in a batch of 20, the package increments an internal counter, so the list is already in sorted order.

Reading the decoder output

  • Version: the digit after the second hyphen. The decoder names versions 1 to 8 as defined in RFC 9562. Other digits are labelled "not defined in RFC 9562", and the all-zero nil UUID shows as version 0.
  • Variant: read from the first digit of the fourth group. 8, 9, a or b means the RFC layout used by almost all UUIDs today. c or d marks an old Microsoft GUID layout.
  • Timestamp: shown in UTC for v7 (milliseconds since 1970) and v1 (100-nanosecond steps since 15 October 1582). Version 6 also holds a time, but the decoder does not read it; other versions have no time.

The decoder needs the hyphenated 36-character form. Braces, a urn:uuid: prefix or a 32-digit value without hyphens are reported as invalid.

Frequently Asked Questions

Can two generated UUIDs be the same?

In practice, no. A v4 UUID has 2^122 possible values. A v7 UUID adds a millisecond timestamp in front of its random bits, so a collision would need two IDs made in the same millisecond with the same random part.

Why does my v7 UUID show a time in the past or future?

The timestamp comes from the clock of the machine that made the ID. A wrong system clock, or an ID made by software that set its own time, gives a misleading date.

Should I store UUIDs as text?

Most databases have a native 16-byte uuid type, such as uuid in PostgreSQL. It takes less than half the space of the 36-character text form and compares faster.

Related Tools

  • ULID Generator - a 26-character, time-sortable alternative to UUID v7, with a ULID/UUID converter.
  • JWT Builder - use a fresh UUID as the jti claim of a test token.