UUID generator for databases, APIs and tests
This UUID generator creates universally unique identifiers directly in your browser. A UUID (called a GUID in the Microsoft world) is a 128-bit number written as 32 hexadecimal digits in five hyphen-separated groups (8-4-4-4-12). Because the values are so large and random, independent systems can create IDs without talking to each other and still avoid collisions.
Every value is built from the Web Crypto API (crypto.getRandomValues), the same cryptographically secure source browsers use for key generation. Nothing is sent to a server, so you can safely generate IDs for private projects.
Anatomy of a UUID
f47ac10b-58cc-4372-a567-0e02b2c3d479
^ ^
| variant (8, 9, a or b = RFC 9562)
version (4 = random, 7 = time-ordered)The first digit of the third group is the version, and the first digit of the fourth group encodes the variant. Everything else is data: random bits for v4, a timestamp plus random bits for v7. You can use these two positions to check which kind of UUID a system produced.
UUID v4 vs UUID v7
| Version 4 | Version 7 | |
|---|---|---|
| Content | 122 random bits | 48-bit Unix timestamp in milliseconds + 74 random bits |
| Sort order | Random | Roughly by creation time |
| Reveals creation time? | No | Yes, to the millisecond |
| Best for | Tokens, public IDs, general use | Database primary keys, event logs |
Version 4 is the default almost everywhere and is the safest choice when you do not want an ID to leak information. Version 7, standardized in RFC 9562 (2024), puts the timestamp first. New rows then land at the end of a B-tree index instead of at random positions, which reduces page splits and keeps inserts fast in PostgreSQL, MySQL and similar databases.
How unique is "unique"?
With 122 random bits, you would need to generate roughly 2.7 quintillion (2.7 × 1018) version 4 UUIDs before the chance of a single duplicate reaches 50%. For practical purposes a well-generated v4 UUID will not collide. The real risk comes from weak random sources, which is why this tool never uses Math.random().
Formatting options explained
- Case – RFC 9562 recommends lowercase output, but parsers must accept both. Some Windows tools and older .NET code print uppercase.
- Hyphens – remove them to get a compact 32-character string, handy for file names or when storing UUIDs in a
CHAR(32)column. - Braces – wrap each value as
{…}, the registry format used for Windows COM class IDs and in many .NET config files.
Common uses
- Seeding test databases and fixtures with realistic primary keys.
- Idempotency keys for payment or messaging APIs, so a retried request is not processed twice.
- Correlation IDs that follow a request through logs of several services.
- Names for uploaded files that must never overwrite each other.
Need other kinds of test values? The random string generator creates tokens from any character set, and the random JSON generator builds full fake records that can include a UUID field.
Things a UUID is not
A UUID is an identifier, not a secret. Do not use v7 values as password-reset tokens, because part of the value is a predictable timestamp. For secrets, generate raw random bytes with the random byte generator instead.
Generate a UUID in Python
The uuid module is part of the standard library, and uuid.uuid4() returns a random version 4 UUID, the same kind this page generates by default. What trips people up is that the result is a UUID object, not a string: json.dumps() rejects it with a TypeError, and comparing it with a string is False even when the text matches, so call str() first. uuid.UUID() goes the other way and accepts uppercase, braces and missing hyphens. Python 3.12 has no uuid.uuid7(); for time-ordered version 7 values, switch the ID type above to UUID v7.
import json
import uuid
u = uuid.uuid4() # random, version 4
print(u) # e.g. 0b0a3f7e-5d0c-4c56-9d3b-6f1f6f3f2a10
print(u.version) # 4
print(str(u).upper()) # uppercase with hyphens
print(u.hex) # 32 hex digits, no hyphens
print("{" + str(u) + "}") # wrapped in braces
# A UUID object is not a string: convert it before JSON or string comparison
print(json.dumps({"id": str(u)}))
# Five at once
print([str(uuid.uuid4()) for _ in range(5)])
# Parse and validate text in any of the common spellings
print(uuid.UUID("{0B0A3F7E-5D0C-4C56-9D3B-6F1F6F3F2A10}"))
When you only need a few IDs for a fixture or a database row, generating them on this page is quicker than opening a REPL.