How to Generate a UUID
A UUID — Universally Unique Identifier — is a 36-character string that looks like f47ac10b-58cc-4372-a567-0e02b2c3d479. Its whole job is to be unique without anyone having to coordinate. You can generate one on your laptop, another on a server in Tokyo, and a third on a phone offline, and the odds of a collision are so small you can treat them as zero. That is why UUIDs show up everywhere developers need an ID: database primary keys, API request IDs, file names, session tokens, event IDs, and message identifiers.
This guide explains what a UUID actually is, why version 4 (random) is the one you almost always want, how to generate one or a hundred in seconds, and how to do it in your own code. If you just need one right now, open the free UUID Generator — it runs entirely in your browser using your device's built-in cryptographic randomness, so nothing is sent to a server.
What a UUID Looks Like
Every UUID is 128 bits, written as 32 hexadecimal digits split into five groups by hyphens, in an 8-4-4-4-12 pattern:
f47ac10b-58cc-4372-a567-0e02b2c3d479
└──────┘ └──┘ └──┘ └──┘ └──────────┘
8 4 4 4 12
Two of those characters are not random — they encode the format itself:
| Position | Meaning |
|---|---|
The digit at the start of the 3rd group (here, 4) | The version. A 4 means it was generated from random numbers. |
The digit at the start of the 4th group (here, a) | The variant. It is always one of 8, 9, a, or b for standard UUIDs. |
So in a version-4 UUID, 122 of the 128 bits are random and 6 are fixed. That is still an astronomically large space — about 5.3 × 10³⁶ possibilities.
One naming note: Microsoft calls these GUIDs (Globally Unique Identifiers). A GUID and a UUID are the same thing — same format, same 8-4-4-4-12 layout. If a tool or database asks for a GUID, a UUID works.
How to Generate a UUID Online
The fastest way is the browser-based UUID Generator. No install, no account, and because it uses your browser's own crypto randomness, the value is generated on your device — not fetched from a server.
- Open the UUID Generator.
- Leave Count set to 1 for a single ID, or type any number up to 100 to generate a batch.
- Click Generate UUID. Your UUID (or list of UUIDs, one per line) appears instantly.
- Hover the result box and click the copy icon to copy everything to your clipboard.
- Need different values? Click Generate again — every click produces fresh random UUIDs.
The tool generates version 4 UUIDs, which is the right default for almost every use case (more on why below). If you need a batch — say, seed IDs for test data or a list of keys — set the count and copy the whole block in one go.
UUID Versions, and Why v4 Is the One You Want
There are several UUID versions. They differ in how the bits are filled, not in the format. Here is the short version of what each one is for:
| Version | Based on | Use it when |
|---|---|---|
| v4 | Random numbers | Almost always. No setup, no inputs, reveals nothing. The default choice. |
| v1 | Timestamp + machine MAC address | You need IDs that sort by creation time — but it can leak the machine and time it was made. |
| v3 / v5 | A hash of a name + namespace | You need the same input to always produce the same UUID (deterministic). |
| v7 | Timestamp + random | A newer option for database keys that need to be time-sortable without leaking a MAC address. |
For the overwhelming majority of jobs — a primary key, a request ID, a unique file name — you want v4. It needs no inputs, depends on nothing about your machine, and gives away no information. That is exactly why the UUID Generator produces v4: it is the safe, boring, correct default.
Are UUIDs Really Unique? (The Collision Question)
UUIDs are not guaranteed unique — they are probabilistically unique, and the probability is the entire point. With 122 random bits, you would need to generate roughly 1 billion UUIDs per second for about 85 years before you had even a 50% chance of a single collision. In practice, that means you can mint them freely across many machines without any central registry and never realistically clash.
Two things to keep in mind:
- Randomness quality matters. A v4 UUID is only as unique as the random number generator behind it. The UUID Generator uses the browser's
crypto.randomUUID()/crypto.getRandomValues(), which is cryptographically strong — not the weakMath.random(). - Uniqueness is not security. A UUID is hard to guess, but it is an identifier, not a secret. Do not use one as a password or an API key. For those, use the Password Generator or a purpose-built token.
How to Generate a UUID in Code
If you are generating UUIDs programmatically, every major language has a one-liner. These all produce a v4 UUID:
| Language | Code |
|---|---|
| JavaScript (browser / Node 19+) | crypto.randomUUID() |
| Python | import uuid; uuid.uuid4() |
| Java | java.util.UUID.randomUUID() |
| C# / .NET | Guid.NewGuid() |
| Go | uuid.New() (github.com/google/uuid) |
| PostgreSQL | gen_random_uuid() |
| Linux / macOS terminal | uuidgen |
When you just need a value to paste into a config file, a test fixture, or a database row by hand, the online generator is faster than opening a terminal — and it can hand you a batch of 100 at once.
Tips
- Store UUIDs efficiently. In a database, a UUID column type (e.g. PostgreSQL
uuid) uses 16 bytes; storing the same value as text uses 36+. Use the native type when you can. - Lowercase is the convention. UUIDs are case-insensitive, but the standard writes them in lowercase. Be consistent so string comparisons don't surprise you.
- Don't strip the hyphens unless you mean to. Some systems store a "bare" 32-character form. That is fine internally, but convert back to the hyphenated form when displaying or exchanging it.
- Use v4 for public-facing IDs. Because v4 reveals nothing about when or where it was made, it is the safe choice for IDs that appear in URLs.
- Generate offline. Because the tool runs client-side, it works with no internet connection once the page has loaded.
Frequently Asked Questions
What is the difference between a UUID and a GUID? ▼
Which UUID version should I use? ▼
Can two UUIDs ever be the same? ▼
crypto API), you can treat UUIDs as unique.Is a UUID secure enough to use as a password or API key? ▼
Can I generate many UUIDs at once? ▼
Are my UUIDs sent to a server? ▼
Should I use a UUID or an auto-increment integer for my database? ▼
Ready to try it?
Use the tool right now — free, no signup, no upload.