UUID generator
Generate random version 4 UUIDs or time-ordered version 7 UUIDs, one or a thousand at a time. Choose uppercase, no hyphens or braces for GUID style. Paste any UUID to see which version it is.
Generated in your browser with the Web Crypto API.
How to use the generator
Pick a version and how many you want. Five appear straight away, and "Generate new UUIDs" makes a fresh batch.
- Version 4 is random. Use it unless you have a reason not to
- Version 7 starts with the current time, so values made later sort after values made earlier. Use it for database keys
- Hyphens, uppercase, braces change how the value is written. Turn on uppercase and braces for the
{3F2504E0-4F89-41D3-9A0C-0305E82C3301}style that Windows tools expect
To find out what an existing UUID is, paste it under "Check a UUID". You'll see its version, and for versions 1, 6 and 7 the moment it was created.
What a UUID is
A UUID is a 128-bit identifier, written as 32 hexadecimal digits in five groups:
f47ac10b-58cc-4372-a567-0e02b2c3d479
The point is that anyone can make one, anywhere, without asking a central authority, and expect it to be unique. That's what "universally unique identifier" means. The format is defined in RFC 9562, which replaced the older RFC 4122 in 2024.
Two digits carry meaning. The first digit of the third group is the version: a 4 there means a random UUID. The first digit of the fourth group encodes the variant, and is 8, 9, a or b for every UUID you're likely to meet.
UUID and GUID
They're the same thing. GUID, for globally unique identifier, is the name Microsoft uses. A GUID made by Guid.NewGuid() in .NET is a version 4 UUID.
The difference is only in how they're usually written: GUIDs often appear in uppercase and inside braces, especially in the Windows registry and in installer files.
UUID versions
| Version | Made from | Use it for |
|---|---|---|
| 1 | Timestamp and a node ID, originally the network card's address | Legacy systems |
| 3 | An MD5 hash of a namespace and a name | The same input always gives the same UUID |
| 4 | Random numbers | General use. The default |
| 5 | A SHA-1 hash of a namespace and a name | Like version 3. Prefer it over 3 |
| 6 | Version 1 with the timestamp reordered so it sorts | Replacing version 1 where compatibility matters |
| 7 | Unix time in milliseconds, then random bits | Database primary keys |
| 8 | Whatever you define | Custom schemes |
The standard says implementations should use version 7 in place of versions 1 and 6 where they can.
Version 4 or version 7?
Version 4 is 122 random bits. Nothing about it reveals when or where it was made. It's the right default for tokens in URLs, request IDs and anything you hand to users.
Version 7 puts a 48-bit timestamp first and fills the remaining 74 bits with random data. Because each new value is larger than the last, it suits database primary keys:
- New rows land at the end of the index, where a random key scatters them across it. On large tables that means fewer page splits and better cache use
- Sorting by ID sorts by creation time
The cost is that a version 7 UUID tells anyone who sees it when it was created. Don't use one where that would leak something, such as the sign-up date of a customer.
Can two UUIDs collide?
In theory. In practice, not with version 4.
There are about 5.3 × 1036 possible version 4 UUIDs. You'd have to generate about 2.7 × 1018 of them to reach a 50% chance that any two match. At a billion per second, that takes 86 years.
That holds only if the random numbers are good. This page uses the browser's cryptographically secure generator. A UUID built from a weak source such as Math.random() can repeat.
Generate a UUID in code
| Language | Version 4 |
|---|---|
| JavaScript | crypto.randomUUID() |
| Python | uuid.uuid4() |
| Ruby | SecureRandom.uuid |
| Java | UUID.randomUUID() |
| C# | Guid.NewGuid() |
| Go | uuid.New() with github.com/google/uuid |
| Swift | UUID().uuidString |
| PowerShell | [guid]::NewGuid() |
| PostgreSQL | SELECT gen_random_uuid(); |
| macOS and Linux | uuidgen |
Version 7 is newer, so support varies. Ruby has SecureRandom.uuid_v7, .NET has Guid.CreateVersion7(), and current PostgreSQL has uuidv7(). Where your language lacks it, a small library fills the gap.
MySQL's UUID() function returns a version 1 value, which is worth knowing before you use it as a key.
GUIDs in installers and apps
If you ship Windows software, you'll need GUIDs that you generate once and then never change.
- An MSI's UpgradeCode identifies your product across versions, so Windows knows that a new installer replaces the old one. The page on MSI vs EXE covers what that's for
- Inno Setup's
AppIddoes the same job for an Inno Setup installer. Change it and your update installs a second copy. There's a full script on the Inno Setup script examples page - COM classes and Visual Studio projects each carry their own
Generate these here with uppercase and braces turned on, paste them into your project, and keep them in source control.
A UUID isn't a secret
UUIDs are designed to be unique. They aren't designed to be unguessable, and versions 1, 6 and 7 are partly predictable by construction.
- For an API key or a session token, use a random secret of at least 128 bits. The API key generator makes those
- For a license key, you need something a customer can type, tied to a purchase. The license key generator makes the format, and the guide to license keys explains what has to sit behind it
Common questions about UUIDs
What is a UUID?
A 128-bit identifier, written as 32 hexadecimal digits in five groups separated by hyphens. It can be generated anywhere without coordination and is unique for all practical purposes.
What is the difference between a UUID and a GUID?
None in substance. GUID is Microsoft's name for a UUID. GUIDs are often written in uppercase with braces around them.
Which UUID version should I use?
Version 4 for general use. Version 7 for database primary keys, where its time ordering keeps indexes compact.
Are UUIDs really unique?
A version 4 UUID has 122 random bits. You'd need to generate about 2.7 × 1018 of them for an even chance of one repeat, so duplicates aren't a practical concern when a good random source is used.
What is a version 7 UUID?
A UUID whose first 48 bits are the Unix time in milliseconds, followed by random bits. Values sort in the order they were created.
How long is a UUID?
128 bits, or 16 bytes. Written out it's 36 characters with hyphens and 32 without.
Can I use a UUID as a primary key?
Yes. Use the database's native UUID type, which stores 16 bytes, and prefer version 7 so new rows are added in order.
Is a UUID safe to use as a password or API key?
Not ideally. UUIDs promise uniqueness, not secrecy, and some versions contain a timestamp. Use a purpose-made random secret.
What is the nil UUID?
00000000-0000-0000-0000-000000000000, all zeros. It's used to mean "no value". The standard also defines a max UUID of all ones.