---
title: What Is a UUID? The Universal ID, Explained | Relic
description: A UUID is a 128-bit identifier you can generate anywhere with no risk of collision. What UUIDs are, how the common versions differ, and when to use one.
canonical: https://relic.space/blog/what-is-a-uuid
source: https://relic.space/llms.txt
---
[Developer copy and paste](https://relic.space/blog/topics/dev-toolbox)

# What is a UUID?

A UUID is a 128-bit identifier built to be unique no matter where it was created, with no central authority handing out numbers. This guide unpacks what that long string of hex actually means, how the common versions differ, and when reaching for one is the right call.

[JGJordan Gibbs](https://relic.space/authors/jordan-gibbs) June 29, 2026 7 min readUpdated September 12, 2026

## What is a UUID in simple terms?

A UUID is a 128-bit identifier, written as 32 hex digits in five hyphenated groups. Any machine can create one on its own, with no central registry, because version 4 fills 122 of those bits with random data. The pool is so large that two UUIDs realistically never collide. Distributed systems and offline apps use them as record ids.

You have seen them everywhere: a string like **f47ac10b-58cc-4372-a567-0e02b2c3d479** sitting in a URL, a database row, a config file, or a log line. That is a UUID, short for Universally Unique Identifier. The whole point of it is in the name. It is a value you can generate on your laptop, on a server in another country, or inside an app on a plane with no signal, and still be confident that nobody else will ever produce the same one.

That sounds like a bold promise, so it helps to understand how the format earns it. Once you see the structure, the magic turns into plain arithmetic, and you will know exactly when a UUID is the right tool and when a simpler number does the job better.

## What does a UUID look like?

A UUID is a 128-bit number. On its own that is just a very large integer, so it is almost always written as 32 hexadecimal digits split into five groups by hyphens, in the [pattern 8-4-4-4-12](https://www.rfc-editor.org/rfc/rfc9562.html). The hyphens are purely for human eyes. They carry no information and you can strip them without changing the value.

Hexadecimal means each digit is one of sixteen symbols, 0 through 9 and a through f, so each digit packs four bits. Thirty-two of those digits give you the full 128 bits. If you find that notation interesting, it is the same base-16 idea that shows up in colour codes and memory addresses, and it sits next to other developer staples like [Base64 encoding](https://relic.space/blog/what-is-base64-encoding) for turning binary into safe text.

## How can it be unique without a central list?

This is the part that sounds impossible at first. No global registry checks whether your UUID has already been used. Uniqueness comes from sheer scale instead. The most common kind, [version 4](https://www.rfc-editor.org/rfc/rfc9562.html), fills 122 of its 128 bits with random data (six bits are reserved to mark the version and variant). That gives you about 5.3 undecillion possible values, a number with 36 zeros.

With a pool that vast, the chance of two random draws matching is so close to zero that engineers treat it as zero. To put it in perspective, you could generate a billion UUIDs every second for around 85 years before the odds of a single collision even reached fifty-fifty. That is why no coordination is needed. The maths does the coordinating.

A UUID is not a secret and not a password. It is unique, not unpredictable in the security sense. Do not use one as an authentication token or to protect a private page. For proving identity you want a signed token like a [JWT](https://relic.space/blog/what-is-a-jwt-token), not a UUID.

## Which UUID version should you use?

The UUID standard defines several versions. They all share the same 128-bit shape, but they fill the bits differently. A digit near the middle of the string tells you which version you are looking at. These are the ones you will actually meet.

### Version 4: random

The workhorse. Almost entirely random, easy to generate, and what most languages and libraries hand you by default. If someone says “a UUID” without qualifying it, they usually mean a v4\. Reach for it when you just need a unique id and do not care about ordering.

### Version 1: time and machine based

Older, and built from a timestamp plus the network card’s MAC address. It is sortable by creation time, which is handy, but it can leak the time and the machine that made it. That privacy quirk is why many teams moved away from it.

### Version 7: time-ordered random

The newer favourite. It puts a millisecond timestamp at the front and fills the rest with random bits, so you get the uniqueness of v4 plus a natural sort order. That ordering makes database indexes much happier, which is the main reason v7 has taken off for primary keys.

## When to use one, and when not to

UUIDs solve a specific problem: creating unique identifiers in more than one place at once, without those places talking to each other. That makes them a natural fit for distributed systems, offline-first apps, and anywhere a record needs an id before it ever reaches a central database.

* **Good fit:** primary keys across many services, ids generated on a phone that syncs later, public-facing identifiers where you do not want to expose how many records you have (an auto-incrementing 1, 2, 3 quietly leaks your size).
* **Poor fit:** a small single-database app where a plain auto-incrementing integer is simpler, smaller, and faster to index. Do not add complexity you will not use.
* **Wrong tool:** anything that needs to be secret or unguessable for security. A UUID is unique, not a credential.

## How do you generate a UUID?

You rarely need to write the logic by hand. Every mainstream environment can produce a UUID in a line or two. In the browser or Node, [**crypto.randomUUID()**](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID) returns a v4\. Python has [**uuid.uuid4()**](https://docs.python.org/3/library/uuid.html). PostgreSQL offers [**gen\_random\_uuid()**](https://www.postgresql.org/docs/current/functions-uuid.html). On a Mac or Linux box you can type **uuidgen** straight into the shell, which is one of those small wins of being comfortable working in the [terminal](https://relic.space/blog/copy-and-paste-in-the-terminal). On Windows PowerShell the equivalent is **\[guid\]::NewGuid()**, since a GUID is just Microsoft’s name for the same thing. And when you want one or two without opening a shell at all, our free [UUID generator](https://relic.space/tools/uuid-generator) creates valid v4 identifiers in your browser, one at a time or in bulk, with nothing sent to a server.

Whichever route you take, the output is the same familiar 36-character string. Generate it, copy it, paste it where it belongs, and trust that it will not clash with anyone else’s. That quiet reliability, with no central list and no coordination, is the whole reason UUIDs are everywhere once you start looking.

## Sources

* [RFC 9562: Universally Unique IDentifiers (UUIDs)](https://www.rfc-editor.org/rfc/rfc9562.html), RFC Editor (2024)
* [UUID Functions](https://www.postgresql.org/docs/current/functions-uuid.html), PostgreSQL Documentation
* [uuid: UUID objects according to RFC 9562](https://docs.python.org/3/library/uuid.html), Python Documentation
* [Crypto: randomUUID() method](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID), MDN Web Docs

## Frequently asked questions

Are UUIDs guaranteed to be unique?+

Not guaranteed in the strict mathematical sense, but the odds of a collision are so small they are ignored in practice. A version 4 UUID has 122 random bits, which is roughly five undecillion possible values. You would need to generate billions of them per second for many years before a duplicate became likely, so teams treat them as unique.

What is the difference between a UUID and a GUID?+

There is no real difference. GUID stands for Globally Unique Identifier and is mostly Microsoft's name for the same 128-bit value defined by the UUID standard. If you see a GUID in a Windows registry or a .NET project, it follows the same format as a UUID. The two terms are interchangeable.

Should I use a UUID as a database primary key?+

You can, and many teams do, because it lets different services create records without asking a central database for the next ID. The trade-off is size and ordering: a UUID is larger than a simple integer and version 4 is random, which can hurt index performance. Version 7 UUIDs are time-ordered and were designed to fix that.

Can I create a UUID without any special software?+

Yes. Most programming languages have a built-in function, databases like PostgreSQL can generate one with a single call, and command line tools such as uuidgen exist on Mac and Linux. If you just need one or two by hand, a browser-based generator is the quickest route.

JG

Written by

[Jordan Gibbs](https://relic.space/authors/jordan-gibbs)Founder, Relic

Jordan Gibbs is the founder of Relic, an end-to-end encrypted, permanent, searchable memory for everything you copy. He writes widely about AI, agents, and practical tooling on Medium, where he is read by tens of thousands, and builds privacy-first software. Here he covers how everyday tools like the clipboard actually work, and how to use them without handing your data to someone else.

[Medium](https://medium.com/@jordan%5Fgibbs)[GitHub](https://github.com/jordan-gibbs)[LinkedIn](https://www.linkedin.com/in/jordan--gibbs/)

Part of

[Developer copy and paste](https://relic.space/blog/topics/dev-toolbox)
* [How to copy and paste in the terminal· pillar](https://relic.space/blog/copy-and-paste-in-the-terminal)
* [What is a JWT token?](https://relic.space/blog/what-is-a-jwt-token)
* [What is a hash function?](https://relic.space/blog/what-is-a-hash-function)
* [What is Base64 encoding?](https://relic.space/blog/what-is-base64-encoding)
* [How to copy a file path](https://relic.space/blog/how-to-copy-a-file-path)
* [Hashing vs encryption: what is the difference?](https://relic.space/blog/hashing-vs-encryption)

Keep reading

[Pillar·13 minHow to copy and paste in the terminalCtrl C cancels a command in the terminal, so copy and paste works differently there. Shortcuts for every terminal, plus SSH, PuTTY, Termius and browser terminals.Read ](https://relic.space/blog/copy-and-paste-in-the-terminal)[7 minWhat is a JWT token?A JWT packs a user's identity into a signed, self-contained token. What the three parts hold, how the signature works, and what a JWT does and does not protect.Read ](https://relic.space/blog/what-is-a-jwt-token)[8 minWhat is a hash function?A hash function squeezes any input into a short, fixed fingerprint you cannot reverse. What hashing is, how it differs from encryption, and where it shows up.Read ](https://relic.space/blog/what-is-a-hash-function)

developerencryption
