Skip to main content

Generate deterministic UUID v5 values

A version 5 UUID is derived from a namespace UUID and a name with SHA-1. Anyone who hashes the same namespace and the same name gets exactly the same UUID, so IDs can be recomputed instead of stored.

Worked example

Namespace (UUID)
DNS (6ba7b810-9dad-11d1-80b4-00c04fd430c8)
Name
example.com
Result
cfbff0d1-9375-5685-968c-48ce8b15ae17
Namespace (UUID)
DNS (6ba7b810-9dad-11d1-80b4-00c04fd430c8)
Name
Example.com
Result
a1feb884-07f5-5a14-8edb-cb659a7fbadc

How it works

  • The 16 namespace bytes are joined with the UTF-8 bytes of the name and hashed with SHA-1. The first 16 bytes of the digest become the UUID after the version (5) and variant bits are set.
  • RFC 9562 predefines namespaces for DNS names, URLs, ISO OIDs, and X.500 distinguished names. Any UUID of your own can also serve as a private namespace.
  • Names are compared byte for byte: letter case, spaces, and trailing slashes all change the result, so normalize names first. Because the output is predictable, never use a v5 UUID as a secret.
UUID Version

Generate 1-100 UUIDs at once

DNS namespace: 6ba7b810-9dad-11d1-80b4-00c04fd430c8 (default)

The name to hash (e.g., domain name, email, etc.)

About UUIDs

UUID v1: Time-based UUIDs that include a timestamp and the MAC address of the computer generating the UUID. Useful when you need to know when the UUID was created.

UUID v4: Randomly generated UUIDs. This is the most commonly used version and provides good uniqueness with minimal information leakage.

UUID v5: Name-based UUIDs using SHA-1 hashing. Given the same namespace and name, you'll always get the same UUID. Useful for deterministic UUID generation.

More UUID guides