Skip to content
DayUtils

UUID Generator – Random v4 and Time-Ordered v7 UUIDs

Generate universally unique identifiers in bulk. Choose random version 4 UUIDs or the newer time-ordered version 7, generate up to a thousand at once, and choose upper or lower case, with or without hyphens. Uses your browser’s secure random number generator.

Loading tool…

How to use the UUID generator

  1. Choose v4 (random) or v7 (time-ordered).
  2. Choose how many you need, from 1 to 1,000.
  3. Tick Uppercase or untick Hyphens if you need a different format.
  4. Press Generate for a fresh set, and Copy to copy them all, one per line.

A set of five UUIDs is ready as soon as the page opens.

UUID structure

A UUID is written as 8-4-4-4-12 hexadecimal digits:

xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx

M is the version (4 or 7) and N is the variant (8, 9, a or b).

  • v4: all other bits are random.
  • v7: the first 48 bits are the Unix time in milliseconds, so UUIDs created later sort after earlier ones; the rest are random.

Example

A v7 UUID beginning with 018bcfe5-6800 was created at Unix time 0x018bcfe56800 milliseconds — 14 November 2023 at 22:13:20 UTC.

v4 or v7?

Use v4 when you want IDs that reveal nothing, such as public identifiers in URLs. Use v7 for database primary keys: because new values always sort after old ones, they are inserted at the end of the index, which keeps databases faster than with fully random keys. Remember that v7 reveals when the ID was created.

Generating UUIDs in code

  • JavaScript: crypto.randomUUID() (v4) in browsers and Node.js.
  • Python: uuid.uuid4(); recent Python versions also add uuid.uuid7().
  • PostgreSQL: gen_random_uuid() for v4.
  • Java: UUID.randomUUID().
  • .NET: Guid.NewGuid().

Storing UUIDs efficiently

As text, a UUID takes 36 characters. Many databases offer a native 16-byte UUID type, which is smaller and faster to index — PostgreSQL has uuid, and MySQL users often store BINARY(16). Keep the hyphenated text form at the edges of your system, such as in APIs and logs, where people need to read it. When comparing UUIDs as text, compare them case-insensitively, because some systems print them in uppercase and others in lowercase.

Other versions

Version 1 used the computer’s MAC address and the time, which leaked information, and version 3 and 5 UUIDs are derived from a name with MD5 or SHA-1, so the same name always gives the same UUID. Versions 4 and 7 cover almost all modern needs.

Common uses

  • Database primary keys, especially in distributed systems.
  • Request and correlation IDs for logs.
  • File names for uploads to avoid clashes.
  • Idempotency keys for payment and API requests.
  • Test data and fixtures.

For random numbers, use the random number generator; for fingerprints of data, the hash generator; for strong passwords, the password generator.

Frequently asked questions

What is a UUID?

A universally unique identifier: a 128-bit value usually written as 32 hex digits in five groups, like 550e8400-e29b-41d4-a716-446655440000. UUIDs let different systems create IDs independently without clashing. Microsoft calls them GUIDs.

What is the difference between UUID v4 and v7?

Version 4 is entirely random (122 random bits). Version 7, standardised in RFC 9562 in 2024, starts with a 48-bit timestamp in milliseconds followed by random bits, so v7 IDs sort in creation order — better for database indexes.

Can two UUIDs be the same?

In theory, but the chance is astronomically small. You would need to generate about a billion v4 UUIDs every second for around 85 years to have a 50% chance of a single duplicate.

Are these UUIDs secure?

They are generated with crypto.getRandomValues, a cryptographically secure source. Still, UUIDs are identifiers, not secrets — don’t use them as passwords or access tokens on their own.

How do I tell a UUID’s version?

Look at the first digit of the third group: 4 for version 4, 7 for version 7. The first digit of the fourth group is 8, 9, a or b for standard UUIDs.

Should I remove the hyphens?

Only if your system needs it. The hyphenated form is the standard text representation, but some databases and APIs store the 32 characters without hyphens.

Last updated: