If you've spent any time working with databases, APIs, or distributed systems, you've almost certainly encountered UUIDs. They look like this: 550e8400-e29b-41d4-a716-446655440000. Seemingly random, oddly specific in format, and absolutely everywhere. But what exactly are they, why are they useful, and which version should you use? Let's break it down.

What Is a UUID?

UUID stands for Universally Unique Identifier. It's a 128-bit label used to uniquely identify information in computer systems. The format is always the same: 32 hexadecimal characters split into five groups by hyphens — 8-4-4-4-12.

The "universally unique" part is the key selling point. UUIDs are designed so that any two independently generated UUIDs will almost certainly be different — even if generated on different machines at the same time, without any coordination between them. This makes them extremely useful in distributed systems where you can't rely on a central authority to assign sequential IDs.

UUIDs are standardized by RFC 4122 and are widely supported across virtually every programming language and database system.

UUID Versions Explained

There are several UUID versions, each generated differently and suited to different use cases. The three most commonly used are v1, v4, and v5.

VersionGeneration MethodUniqueness SourcePredictable?Common Use Case
v1Timestamp + MAC addressTime + hardwarePartiallyEvent logging, audit trails
v4RandomPure randomnessNoGeneral purpose, databases
v5Namespace + name (SHA-1)DeterministicYes (same input → same UUID)Consistent IDs for known resources

UUID v1 — Timestamp-Based

v1 UUIDs encode the current timestamp and the MAC address of the machine generating them. They're time-ordered, which can be useful for sorting. However, they leak information — if you inspect a v1 UUID, you can extract when and where (roughly) it was created. For privacy-sensitive applications, this is a concern.

UUID v4 — Random

v4 is the most widely used version today. It's generated from 122 bits of randomness (the other 6 bits encode the version and variant). There's no timestamp, no machine info — just random data. The probability of two v4 UUIDs colliding is so astronomically low it's effectively impossible in practice. When in doubt, use v4.

UUID v5 — Name-Based (SHA-1)

v5 generates a UUID from a namespace UUID and a name string, using SHA-1 hashing. The same namespace + name always produces the same UUID. This is useful when you want a consistent, reproducible identifier for a known resource — for example, always generating the same UUID for a given URL or user email. Note: v3 does the same thing but with MD5 (less preferred today).

Common Use Cases for UUIDs

UUIDs are versatile. Here's where developers reach for them most often:

Database primary keys Instead of auto-incrementing integers, many applications use UUID primary keys. The advantage: records can be created across multiple servers or clients without ID collisions, and the IDs don't expose how many records exist in your database.

File naming and storage When uploading user files to object storage (S3, R2, etc.), using a UUID as the filename prevents conflicts and avoids exposing the original filename to the storage layer.

Session IDs and tokens UUIDs make great session identifiers — long enough to be unguessable, short enough to be practical. Most web frameworks will generate UUID-based session tokens out of the box.

Distributed event tracking In event-driven or microservice architectures, UUIDs are used as correlation IDs to trace a request across multiple services in logs and monitoring systems.

Client-side ID generation In offline-first apps or mobile clients, records can be created on the device with a UUID before syncing to the server. No round-trip to the server needed just to get an ID.

UUID v4 vs v1 vs v5 — Which Should You Use?

The short answer for most use cases:

  • Use v4 if you just need a unique, opaque ID and don't need it to be reproducible.
  • Use v1 if you need time-sortable IDs and privacy is not a concern.
  • Use v5 if you need to derive a consistent ID from a known name or resource.

For new projects, v4 is the safe default unless you have a specific reason to choose otherwise.

How to Generate a UUID Online

If you need a UUID for testing, development, or configuration, you don't need to write any code. ujiffy's free UUID generator lets you:

  • Generate one or multiple UUIDs at once
  • Choose between v1, v4, and v5 versions
  • Copy results to clipboard instantly
  • Everything runs in your browser — no server involved

No sign-up, no rate limits, no tracking.

For developers who need UUIDs in code, here are quick snippets:

// JavaScript (browser or Node 14.17+)
crypto.randomUUID() // generates a v4 UUID

// Python
import uuid
str(uuid.uuid4())

// Go
import "github.com/google/uuid"
uuid.New().String()

But if you just need one right now — the generator is faster.

Final Thoughts

UUIDs are a simple but powerful primitive in software development. They solve the "how do I generate a unique ID without coordination?" problem elegantly. For most applications, v4 is all you need. If you're building something more specific — time-ordered logs, or deterministic IDs for known resources — v1 or v5 have you covered.

Try ujiffy UUID Generator →