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.