Definition
A UUID namespace is a UUID value used as a parameter to the deterministic UUID v3 and v5 generation algorithms. The namespace scopes the name-to-UUID mapping — the same name string produces different UUIDs in different namespaces.
UUID v5 = SHA1(namespace_bytes || name_bytes), formatted as UUID
The four standard namespaces are pre-defined by RFC 9562 (and the earlier RFC 4122) for common identifier types.
The four standard namespaces
| Namespace | UUID | Use case |
|---|---|---|
| DNS | 6ba7b810-9dad-11d1-80b4-00c04fd430c8 | Domain names |
| URL | 6ba7b811-9dad-11d1-80b4-00c04fd430c8 | URLs and URIs |
| OID | 6ba7b812-9dad-11d1-80b4-00c04fd430c8 | ISO Object Identifiers |
| X500 | 6ba7b814-9dad-11d1-80b4-00c04fd430c8 | X.500 Distinguished Names |
Note: 6ba7b813 (X500 variant) is not a standard namespace — only the four above are defined in RFC 9562.
DNS namespace — deterministic UUID from domain name
import { v5 as uuidv5 } from 'uuid';
const DNS_NAMESPACE = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
// Always the same UUID for 'example.com'
const id = uuidv5('example.com', DNS_NAMESPACE);
// → 'cfbff0d1-9375-5685-968c-48ce8b15ae17'
// Different domain = different UUID
const id2 = uuidv5('other.com', DNS_NAMESPACE);
// → different UUID, always the same for 'other.com'
URL namespace — deterministic UUID from URL
const URL_NAMESPACE = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
// Deterministic UUID for a specific API endpoint
const endpointId = uuidv5('https://api.example.com/products/123', URL_NAMESPACE);
// Useful for: content deduplication, canonical IDs for URLs
// Same URL always maps to the same UUID
URL namespace UUIDs are useful for generating stable IDs for web resources — if the URL is the canonical identifier, uuidv5(url, URL_NAMESPACE) gives a fixed 128-bit ID that can be used as a database key. See UUID v5 — Deterministic UUIDs.
Custom application namespace
import { v4 as uuidv4, v5 as uuidv5 } from 'uuid';
// Generate once, store as a constant in your application
const MY_APP_NAMESPACE = 'a8098c1a-f86e-4da4-bd1a-00112444be1e'; // your UUID v4
// Deterministic product ID from slug
const productId = uuidv5('widget-pro', MY_APP_NAMESPACE);
// Same on every run — stable across deployments
// Deterministic user ID from email
const userId = uuidv5('alice@example.com', MY_APP_NAMESPACE);
A custom namespace ensures your deterministic UUIDs are scoped to your application — another application using the same slug with a different namespace produces a different UUID, preventing cross-application collisions. See UUID Namespaces — full guide.
When to use namespace UUIDs vs UUID v7
| Use case | Recommended |
|---|---|
| New database primary key | UUID v7 |
| Deterministic ID from a name | UUID v5 (namespaced) |
| Idempotent resource creation | UUID v5 (deterministic) |
| Content deduplication by URL | UUID v5 (URL namespace) |
| Trace/correlation ID | UUID v7 |
UUID v7 and UUID v5 are complementary — v7 for new unique IDs, v5 for stable IDs derived from known names. See UUID v4 vs v7 for when to use each random version.
Related terms
- UUID v5 — Deterministic Namespace-Based UUIDs
- UUID v3 — MD5 Name-Based UUID
- UUID Namespaces — full developer guide
- Namespace — UUID concept overview
Frequently asked questions
What are the four standard UUID namespaces?
RFC 9562 defines four pre-defined namespace UUIDs: DNS (6ba7b810-9dad-11d1-80b4-00c04fd430c8) for domain names, URL (6ba7b811-9dad-11d1-80b4-00c04fd430c8) for URLs, OID (6ba7b812-9dad-11d1-80b4-00c04fd430c8) for ISO OIDs, and X500 (6ba7b814-9dad-11d1-80b4-00c04fd430c8) for X.500 Distinguished Names. These are used as the namespace argument in UUID v3 (uuidv3(name, namespace)) and UUID v5 (uuidv5(name, namespace)).
What is the difference between UUID v3 and v5 namespaced UUIDs?
UUID v3 uses MD5 hashing — it is deprecated in RFC 9562 due to MD5 collision vulnerabilities. UUID v5 uses SHA-1 — it is the recommended choice for new systems needing deterministic UUIDs. Both produce the same UUID for the same (namespace, name) pair. Use UUID v5 for new code. See UUID v5 — Deterministic Namespace-Based UUIDs.
Can I define my own custom UUID namespace?
Yes. Any UUID can be used as a namespace — generate a UUID v4 once and store it as your application's private namespace. This is a common pattern for application-specific deterministic IDs: uuidv5('product/123', MY_APP_NAMESPACE) always produces the same UUID for product/123 within your application, but differs from what another application would produce for the same string.