Definition

Entropy in the context of UUIDs refers to the number of unpredictable bits in the identifier — the bits whose values come from a random source rather than from a fixed algorithm, timestamp, or deterministic computation.

Higher entropy means:

  1. Lower collision probability — more possible values, less chance two generators produce the same UUID
  2. Higher unpredictability — harder for an attacker to guess or enumerate valid UUIDs

How many bits of entropy does a UUID have?

The answer depends on the version:

VersionTotal bitsEntropy bitsSource
v1128~62Timestamp + MAC address (mostly deterministic)
v31280MD5 hash of namespace + name (fully deterministic)
v4128122CSPRNG — 6 bits used for version/variant
v51280SHA-1 hash of namespace + name (fully deterministic)
v71287448-bit timestamp + CSPRNG for remainder

UUID v4 is the highest-entropy version. UUID v7 trades 48 bits of timestamp for 74 bits of randomness — still far more than enough for collision safety, though slightly more predictable than v4.

Where UUID randomness comes from

UUID libraries use a Cryptographically Secure Pseudo-Random Number Generator (CSPRNG), which sources entropy from the operating system’s kernel entropy pool. The kernel accumulates randomness from hardware events (disk I/O timing, interrupt timing, hardware RNG chips on modern CPUs).

PlatformCSPRNG API
Browsercrypto.getRandomValues()
Node.jscrypto.randomFillSync() / crypto.randomUUID()
Pythonos.urandom() (used internally by uuid.uuid4())
Gocrypto/rand.Read()
JavaSecureRandom
.NETRandomNumberGenerator

Never use Math.random() or equivalent for UUID generation. Math.random() is a non-cryptographic PRNG with only ~52 bits of state, meaning it can be seeded and predicted.

Entropy vs security

High entropy makes UUIDs unpredictable, but a UUID is not a secret. Even with 122 bits of randomness, a UUID v4 should not be used as a password, session token, or API key on its own because:

For secrets, generate a purpose-built random token (e.g., 32 bytes from crypto.getRandomValues(), encoded as Base64 or hex) and protect it like a password.

Entropy and UUID v7 timestamp

UUID v7 embeds a 48-bit Unix millisecond timestamp in the most significant bits. This means:

Checking entropy quality

You can verify your UUID library uses a CSPRNG by checking its source code or documentation. All well-maintained UUID libraries (the uuid npm package, Python’s uuid module, Go’s google/uuid, .NET’s Guid.NewGuid()) use OS-level CSPRNG APIs.

A sign of a low-quality UUID library: it uses Math.random(), rand(), or any language’s default non-secure random function.

Generate high-entropy UUIDs with the UUID v4 generator or UUID v7 generator.

Frequently asked questions

Where does UUID randomness come from?

UUID v4 and the random bits in v7 come from a Cryptographically Secure Pseudo-Random Number Generator (CSPRNG) — crypto.getRandomValues() in browsers and Node.js, os.urandom() in Python, crypto/rand in Go. Never use Math.random() or equivalent for UUID generation.

Are these UUIDs cryptographically secure?

The randomness is, yes — it comes from the Web Crypto API. That said, a UUID is an identifier, not a secret; don't use one as a password or an unguessable capability token on its own.

How many bits of entropy does UUID v4 have?

UUID v4 has 122 bits of entropy — 128 total bits minus 4 version bits and 2 variant bits. All 122 bits come from a CSPRNG such as crypto.getRandomValues() in browsers or os.urandom() in Python. This makes UUID v4 collision probability negligible and values computationally infeasible to guess.

Does UUID v7 have less entropy than v4?

Yes — UUID v7 uses 74 bits of randomness (62 in rand_b plus up to 12 in the monotonic counter) compared to v4's 122 bits. The remaining bits are the 48-bit timestamp and structural fields. 74 bits is still more than sufficient for collision resistance in any real workload. The trade-off is documented in RFC 9562 §5.7 alongside the reasoning for the timestamp-first design.

Why does UUID entropy matter for security?

Low-entropy UUIDs can be guessed or enumerated, enabling attackers to access resources by ID — an IDOR (Insecure Direct Object Reference) vulnerability documented by OWASP. UUID v4 with 122 CSPRNG bits is safe for use in bearer tokens and external IDs. UUID v7's timestamp is publicly readable and slightly reduces the guessing space; use v4 for externally-visible security-sensitive identifiers.