What Is a UUID? How to Generate a UUID (v4) and When to Use It

If you have ever opened a database, an API response or a log file and seen a long string like 550e8400-e29b-41d4-a716-446655440000, you have met a UUID. It looks random, it looks unreadable, and it is everywhere — from user accounts and order IDs to file names and session tokens.

And yet most people who copy-paste one every day have never been told what it actually is, why it has those dashes, or why there are different versions of it. This guide fixes that. No maths degree needed.

What is a UUID?

UUID stands for Universally Unique Identifier. It is a 128-bit number, written as 32 hexadecimal characters grouped in five blocks separated by hyphens, in the pattern 8-4-4-4-12:

xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx

The M tells you the version (for example, 4 means version 4). The N tells you the variant — for the standard variant used almost everywhere, it is 8, 9, a or b.

The whole point of a UUID is in the name: universal uniqueness. Two different computers, with no connection to each other, can each generate a UUID and be confident they will never accidentally generate the same one. That is why UUIDs are used as IDs in distributed systems — nobody has to ask a central server “is this ID taken yet?”

The format was first standardised in RFC 4122 back in 2005, and updated in RFC 9562 in 2024, which added the newer versions 6, 7 and 8. The idea itself is older than most of the apps that use it.

Why not just use 1, 2, 3?

Counting up from 1 works fine — until it doesn’t. Sequential IDs leak information (anyone can guess that order #1042 exists if they have seen #1041), they break when two systems merge (both have a user #57), and they need a central counter, which becomes a bottleneck.

A UUID solves all three problems at once: it is unpredictable, it needs no coordination, and merging two databases full of UUIDs just works. The price you pay is length — 36 characters instead of a few digits — and the fact that humans cannot remember them. For a machine, that trade is almost always worth it.

UUID versions explained: v1, v4, v5 and v7

Not all UUIDs are made the same way. The version digit tells you how it was built — and that matters, because each version has different strengths.

VersionHow it is madeBest for
v1Timestamp + MAC address of the machineLegacy systems; rarely chosen for new work
v4Purely random (122 random bits)The default choice for most apps
v5SHA-1 hash of a namespace + a nameSame input must always give the same ID
v7Unix timestamp + random bits, time-orderedDatabase primary keys, new projects in 2026

Version 4 is the one you will meet most often, and it is the one our free UUID Generator creates. It uses 122 bits of randomness, which is what makes collisions practically impossible (more on that below). If you are unsure which version to pick, pick v4.

Version 1 embeds the time it was created and the network card address of the machine. That was clever in the 1990s and is a privacy problem now — a v1 UUID can reveal when and on which machine it was made. Avoid it in new projects.

Version 5 is deterministic: feed it the same namespace and the same name, and you always get the same UUID. That is useful when you need a stable ID derived from something else — for example, generating the same ID for the same email address every time, without storing a mapping table. Version 3 is the same idea built on MD5 instead of SHA-1; v5 is the better choice of the two.

Version 7, added in the 2024 standard, is the modern answer for databases. It starts with a millisecond timestamp, so UUIDs sort in roughly the order they were created — which keeps database indexes fast — and the rest is random. If you are starting a new project in 2026 and your database will hold millions of rows, v7 deserves a serious look.

How likely is a UUID collision, really?

This is the question everyone asks, and the answer is: so unlikely that you can stop worrying about it.

A version 4 UUID has 122 random bits, which means there are about 5.3 × 10³⁶ possible values. The birthday-paradox maths says you would need to generate around 2.7 × 10¹⁸ UUIDs — roughly a billion per second for about 85 years — before the chance of even one duplicate reaches 50%.

In practice, that means your app will run out of disk space, money and patience many orders of magnitude before it ever sees a duplicate UUID. Collisions are a theoretical footnote, not a real-world risk.

How to generate a UUID

Option 1: Use a free online generator (fastest)

  1. Open the UUID Generator on SoftTools.
  2. Click generate — a fresh version 4 UUID appears instantly.
  3. Copy it with one click and paste it wherever you need it.

Everything runs in your browser, so the UUID you generate is never sent to a server or stored anywhere. If you need several at once, generate them one by one — each click gives you a brand-new random value.

Option 2: Generate one in code

Most languages have it built in, so you rarely need a library:

  • JavaScript: crypto.randomUUID() in modern browsers and Node.js.
  • Python: import uuid then uuid.uuid4().
  • Java: UUID.randomUUID().
  • C#: Guid.NewGuid().
  • PHP: ramsey/uuid is the standard library, or use random_bytes() to build one manually.
  • Command line: on Linux, uuidgen prints a fresh UUID; on macOS, uuidgen works the same way.

If you are writing a quick script, use the built-in function. If you need a single UUID right now and do not want to open a terminal, the online generator is faster.

When to use a UUID

UUIDs are a good fit whenever an ID must be unique across systems, users or time:

  • Database primary keys — especially when data is created on phones, browsers or multiple servers that sync later.
  • Public-facing IDs — order IDs, invoice numbers and share links, where you do not want people guessing the next one.
  • File names — uploaded files get a UUID name so two users uploading photo.jpg never overwrite each other.
  • Session and API tokens — as an opaque reference (not as the secret itself — see below).
  • Distributed systems — microservices, event logs and message queues, where a central ID counter would be a bottleneck.

When NOT to use a UUID

A UUID is a hammer, and not every ID problem is a nail:

  • Do not use a UUID as a password. It is random, but it is not designed as a secret, and people will paste it into logs, URLs and screenshots. Use the Password Generator for passwords.
  • Do not use it where a short ID is needed. Nobody wants to read a 36-character order number over the phone. A short, human-friendly code is better there.
  • Do not use it for sorting by creation time — unless you choose v7. Random v4 UUIDs have no order at all, which can slow down database inserts on very large tables.
  • Do not use it as a security token on its own. A UUID can identify a session, but authorisation must still be checked on the server. Knowing someone’s UUID should never be enough to impersonate them.

UUID vs other IDs

  • UUID vs auto-increment integer: integers are short, fast and sortable, but predictable and hard to merge across systems. UUIDs are the opposite. Many modern apps use both — a UUID for the public ID, an integer internally.
  • UUID vs ULID: a ULID is also 128 bits, but it is time-ordered and uses a shorter, URL-safe alphabet. It is a good alternative if you like v7’s ordering but want a more compact string.
  • UUID vs Nano ID: Nano IDs are shorter and URL-friendly, and are popular for public short IDs. They are random like v4 UUIDs, but they are not a standard — two libraries can produce incompatible formats.
  • UUID vs hash (MD5 / SHA-256): a hash is derived from some input, so the same input always gives the same hash. A v4 UUID is random, so the same “input” (none) gives a different value every time. Use a hash when you need determinism; use a UUID when you need a fresh unique value.

FAQs

1. Is a UUID always unique?
Practically, yes. A version 4 UUID has 122 random bits, so a collision is so unlikely it can be ignored in real systems. It is not mathematically guaranteed — that is why the name says “universally unique” rather than “guaranteed unique”.

2. What does a UUID look like?
Thirty-two hexadecimal characters in five groups — 8-4-4-4-12 — like 550e8400-e29b-41d4-a716-446655440000. Lowercase is the usual convention.

3. Which UUID version should I use?
Version 4 for almost everything. Version 7 if you are building a new database-heavy app in 2026 and want time-ordered IDs. Version 5 when the same input must always produce the same ID.

4. Can I generate a UUID offline?
Yes. The SoftTools UUID Generator runs entirely in your browser, and command-line tools like uuidgen need no internet at all. Nothing about generating a UUID requires a server.

5. Is a UUID safe to put in a URL?
Yes — UUIDs only contain hexadecimal digits and hyphens, both URL-safe. Just remember that anyone who sees the URL can see the ID, so never use a bare UUID as the only proof that someone is allowed to access something.

6. How is a UUID different from a GUID?
A GUID is Microsoft’s name for essentially the same thing. For practical purposes, UUID and GUID are interchangeable — a GUID is a UUID as implemented in Windows.

Conclusion

A UUID is one of those quiet pieces of infrastructure the modern internet runs on: a 128-bit ID that any computer can generate on its own, with no coordination, and be confident it will never clash with anyone else’s. Version 4 is the safe default, version 7 is the modern choice for databases, and version 5 covers the cases where the same input must always give the same ID.

Next time you need a fresh, unique ID — for a database row, an uploaded file or an API resource — generate one in seconds with the free UUID Generator on SoftTools, and get back to building.

Rahul

Rahul runs SoftTools from India. He builds free, private online tools that work entirely in your browser, and writes practical guides that explain everyday calculations and web tools in plain language.

← Back to all tools

2 responses to “What Is a UUID? How to Generate a UUID (v4) and When to Use It”