Irreva logo
Explore Irreva
DeveloperMarch 19, 2026· 6 min read· Updated June 10, 2026

UUID Explained for Beginners — What They Are and Why They Matter

Hasanur Rahman

Written by Hasanur Rahman

Founder & Full-Stack Developer · Irreva · Rangpur, Bangladesh

If you've worked with any database, API, or web application for more than a few weeks, you've almost certainly encountered a UUID — something like 550e8400-e29b-41d4-a716-446655440000. They look random and a bit unwieldy, but they're everywhere for good reasons. This guide explains what UUIDs are, why developers prefer them over simple sequential IDs, and what the different versions mean.

What is a UUID?

UUID stands for Universally Unique Identifier. It's a 128-bit number, typically displayed as 32 hexadecimal digits in five groups separated by hyphens: 8-4-4-4-12. The format is standardized in RFC 4122.

The defining property of a UUID is that it's unique — not just within your database or your application, but in theory across all systems that generate UUIDs. The probability of generating two identical UUID v4s is so small (1 in 5.3×10^36) that it's treated as impossible in practice.

Why use UUIDs instead of sequential integers?

Sequential IDs (1, 2, 3...) are simple and efficient in a single database, but they create problems at scale. They reveal information about your data — a user with ID 12 can infer that only 11 users signed up before them. They create security issues when IDs appear in URLs (someone can easily enumerate resources by incrementing the number). And they become a coordination problem in distributed systems where multiple databases or services need to assign IDs independently.

UUIDs solve all of these problems. They can be generated anywhere — in the client browser, in different microservices, in separate database servers — without any central coordination, and collisions are practically impossible. The trade-off is that they're larger (16 bytes vs 4 bytes for a 32-bit integer) and don't sort naturally by creation time.

UUID versions — v1, v4, v7, and what's different

UUID v1 includes the machine's MAC address and a timestamp. This makes them time-sortable, which is useful for database indexing, but it exposes the generating machine's network address — a privacy concern that led to limited adoption.

UUID v4 is the most common version. It's generated from random bytes. The only structure is a few fixed bits that identify the version and variant. Because it's purely random, it has no inherent ordering, which can hurt database index performance at high insert rates.

UUID v7 is a newer standard that combines a Unix timestamp with random bits. This gives you UUIDs that sort chronologically — making them database-friendly like v1 — without exposing any hardware information. If you're starting a new project, v7 is worth considering. For most existing use cases, v4 is fine.

How UUIDs are generated in a browser

The Web Crypto API, which is built into every modern browser, provides `crypto.randomUUID()` — a native method that generates cryptographically secure UUID v4 strings. This is the same API used by the UUID Generator on Irreva.

Because the generation uses the browser's secure random number generator, there's no server involved and no possibility of the same UUID being returned to two different callers. The method is also fast — generating thousands of UUIDs takes milliseconds.

Frequently Asked Questions

Are UUIDs truly unique?

Statistically yes, to a degree that makes collisions a non-issue in practice. UUID v4 has 122 random bits, giving 5.3×10^36 possible values. If you generated one billion UUIDs per second for a billion years, the probability of a collision would still be negligibly small.

What's the difference between UUID and GUID?

GUID (Globally Unique Identifier) is Microsoft's implementation of the UUID standard. They follow the same RFC 4122 format and are functionally identical. The term GUID is common in Windows and .NET development; UUID is the broader standard term.

Should I use UUID v4 or v7 for a new project?

If your UUIDs will be used as primary keys in a database, v7 is generally better because its timestamp prefix makes them sort-friendly, which improves B-tree index performance. For most other uses (session tokens, file names, external references), v4 is perfectly fine.

Can I use a UUID as a URL slug?

You can, but it makes for ugly, unreadable URLs. A better approach is to use a UUID internally as a primary key and use a separate human-readable slug in URLs, with a database lookup connecting them.

How do I generate a UUID in different programming languages?

Python: `import uuid; str(uuid.uuid4())`. Node.js: `crypto.randomUUID()` (built-in) or the uuid package. PHP: `Str::uuid()` in Laravel. Go: the google/uuid package. Ruby: `SecureRandom.uuid`. Most languages have UUID generation either built in or via a well-maintained package.

Hasanur Rahman

About the author

Hasanur Rahman

Founder & Full-Stack Developer · Irreva · Rangpur, Bangladesh

Hasanur Rahman is the founder of Irreva and a full-stack developer based in Rangpur, Bangladesh. He builds all of Irreva's tools with a focus on privacy-first, browser-based processing.