UUID Generator (v4 / v7)

Generate UUIDs (GUIDs) for database keys, file names or test data. They are created in your browser using a cryptographically secure random source (crypto.getRandomValues).

Inspect a UUID

What is a UUID?

A UUID (Universally Unique Identifier) is a 128-bit value written as 32 hexadecimal digits in five groups, such as 550e8400-e29b-41d4-a716-446655440000. Anyone can generate one independently, without a central registry, and still be practically certain it is unique. Microsoft calls the same thing a GUID. UUIDs are defined in RFC 9562 (2024), which replaced RFC 4122.

The first digit of the third group is the version (the 4 in 41d4 above), and the first digit of the fourth group encodes the variant (8, 9, a or b for standard UUIDs).

UUID v4 vs v7

VersionContentsGood for
v4122 random bitsGeneral-purpose IDs that should not be guessable or reveal anything
v748-bit Unix timestamp in milliseconds + random bitsDatabase primary keys (sorted by creation time)
v1Timestamp + node ID (often the MAC address)Legacy systems; leaks the host's MAC address

Because v4 values are completely random, inserting them as primary keys scatters writes across a B-tree index, which can hurt insert performance and cache locality. v7 UUIDs sort by creation time, so new rows land at the end of the index, much like an auto-increment key — while remaining globally unique.

All UUID versions at a glance

VersionHow it is madeNotes
v1Timestamp (100 ns since 1582) + node IDNode ID is often the MAC address
v3MD5 hash of a namespace + nameSame input always gives the same UUID
v4RandomThe most common version
v5SHA-1 hash of a namespace + namePreferred over v3 for name-based IDs
v6v1 with the timestamp reorderedSortable; mainly for migrating from v1
v7Unix time in ms + randomRecommended for new time-ordered IDs
v8Custom, vendor-defined layoutOnly the version and variant bits are fixed
Nil / Max00000000-0000-0000-0000-000000000000 / ffffffff-…-ffffffffffffSpecial values, e.g. “no ID yet”

Name-based UUIDs are deterministic: in Python, uuid.uuid5(uuid.NAMESPACE_DNS, 'example.com') is always cfbff0d1-9375-5685-968c-48ce8b15ae17. Use them when the same name must map to the same ID on every system.

Anatomy of a UUID v7

The 36-character text form is 32 hex digits in groups of 8-4-4-4-12. In a v7 UUID the 128 bits are laid out like this:

BitsFieldExample 0192f3a4-5b6c-7d8e-9f01-23456789abcd
48Unix timestamp in milliseconds0192f3a45b6c = 2024-11-03T20:08:07.788Z
4Version7
12Random (or a sub-millisecond counter)d8e
2Variant (binary 10)the top bits of 9
62Randomthe rest of 9f01-23456789abcd

Storing UUIDs in a database

Store UUIDs in a 16-byte binary form rather than as 36-character text — it uses less than half the space and makes indexes smaller and faster. PostgreSQL has a native uuid type. In MySQL, use BINARY(16) with UUID_TO_BIN() and BIN_TO_UUID(). SQL Server's uniqueidentifier sorts by a different byte order than the text form, so time-ordered UUIDs may not stay in order there.

Can two UUIDs collide?

A v4 UUID has 122 random bits, or about 5.3 × 1036 possible values. By the birthday bound you would need to generate roughly 2.7 × 1018 v4 UUIDs before the chance of even one duplicate reaches 50% — about 86 years at one billion UUIDs per second. In practice, a collision is far more likely to come from a broken random number generator than from chance.

Generate a UUID in code

LanguageCode
JavaScriptcrypto.randomUUID() (v4)
Pythonstr(uuid.uuid4())
JavaUUID.randomUUID() (v4)
C# / .NETGuid.NewGuid() (v4), Guid.CreateVersion7() (.NET 9+)
PostgreSQLgen_random_uuid() (v4), uuidv7() (PostgreSQL 18+)
MySQLUUID() (v1)
Linux / macOSuuidgen

Frequently asked questions

Can I use a UUID as a password or secret token?

A v4 UUID from a secure random source is hard to guess, but it carries only 122 random bits and was not designed as a secret — not every library guarantees a cryptographically secure source. Use a dedicated token generator for secrets, and never use v1 or v7 UUIDs, which contain a readable timestamp.

Should UUIDs be uppercase or lowercase?

RFC 9562 says UUIDs should be output in lowercase and compared case-insensitively. Some environments, such as the Windows registry, display GUIDs in uppercase and often wrap them in braces — use the options above to match.

Can I get the creation time from a UUID v7?

Yes. The first 48 bits of a v7 UUID are a Unix timestamp in milliseconds. Paste a v7 (or v1 / v6) UUID into “Inspect a UUID” above to see the embedded time. For example, 0192f3a4-5b6c-7d8e-… was created at 2024-11-03T20:08:07.788Z.