Developer7 min readUpdated 2026-06-29

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:

PositionMeaning
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.

  1. Open the UUID Generator.
  2. Leave Count set to 1 for a single ID, or type any number up to 100 to generate a batch.
  3. Click Generate UUID. Your UUID (or list of UUIDs, one per line) appears instantly.
  4. Hover the result box and click the copy icon to copy everything to your clipboard.
  5. 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:

VersionBased onUse it when
v4Random numbersAlmost always. No setup, no inputs, reveals nothing. The default choice.
v1Timestamp + machine MAC addressYou need IDs that sort by creation time — but it can leak the machine and time it was made.
v3 / v5A hash of a name + namespaceYou need the same input to always produce the same UUID (deterministic).
v7Timestamp + randomA 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 weak Math.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:

LanguageCode
JavaScript (browser / Node 19+)crypto.randomUUID()
Pythonimport uuid; uuid.uuid4()
Javajava.util.UUID.randomUUID()
C# / .NETGuid.NewGuid()
Gouuid.New() (github.com/google/uuid)
PostgreSQLgen_random_uuid()
Linux / macOS terminaluuidgen

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?
None, in practice. GUID (Globally Unique Identifier) is Microsoft's name for the same 128-bit identifier the rest of the world calls a UUID. Same format, same 8-4-4-4-12 layout. If a Windows or .NET tool asks for a GUID, a UUID from this generator works.
Which UUID version should I use?
Version 4 (random) for almost everything — it needs no setup and reveals nothing about your machine. Use v5 only when you need the same input to always produce the same UUID, and consider v7 if you specifically need database keys that sort by time. This tool generates v4, which is the correct default.
Can two UUIDs ever be the same?
It is theoretically possible but practically impossible. A v4 UUID has 122 random bits — about 5.3 × 10³⁶ values. You would need to generate a billion per second for roughly 85 years to reach a 50% chance of one collision. As long as the generator uses strong randomness (this one uses the browser's crypto API), you can treat UUIDs as unique.
Is a UUID secure enough to use as a password or API key?
No. A UUID is an identifier, not a secret. It is hard to guess, but it is meant to be shared and often appears in URLs and logs. For passwords use the Password Generator, and for API keys use a dedicated token system designed to be kept secret.
Can I generate many UUIDs at once?
Yes. Set the Count field on the UUID Generator to any number up to 100 and click Generate. You will get that many UUIDs, one per line, and the copy button grabs the whole list at once — handy for seeding test data or pre-allocating keys.
Are my UUIDs sent to a server?
No. The generator runs entirely in your browser using your device's built-in cryptographic random number generator. The UUIDs are created on your machine and never transmitted anywhere — the tool even works offline once the page has loaded.
Should I use a UUID or an auto-increment integer for my database?
Use a UUID when records are created across multiple servers or offline and you can't rely on a central counter, or when you don't want IDs to reveal how many records exist or be guessable in a URL. Use an auto-increment integer when everything writes to one database and you want the smallest, fastest-to-index keys. Many teams use both: an internal integer key plus a public UUID.

Ready to try it?

Use the tool right now — free, no signup, no upload.