UUID Generator
Generate and validate universally unique identifiers
Uses Web Crypto API for cryptographically secure random generation. All processing happens locally in your browser.
Component Breakdown
Validates UUID format, version, and variant according to RFC 4122 specification.
Batch Validation
All conversions preserve the original UUID value. Different formats are used by different systems and programming languages.
UUID Structure
xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
| | | | |
| | | | +-- Node (48 bits)
| | | +-------------- Clock Seq (14 bits)
| | +--------------------- Version (M = 1-5)
| +---------------------------- Time Mid (16 bits)
+-------------------------------------- Time Low (32 bits)
M = Version (4 bits):
1 = Timestamp + MAC address
2 = DCE Security (rarely used)
3 = MD5 hash (namespace)
4 = Random <-- Most common
5 = SHA-1 hash (namespace)
N = Variant (first 2-3 bits):
10xx = RFC 4122 (standard)
110x = Microsoft COM/DCOM
111x = Reserved for future
Version Comparison
| Use Case | Recommended Version | Why |
|---|---|---|
| Database primary keys | Version 4 | Cryptographically random, no collisions |
| Need temporal sorting | Version 1 or ULID | Timestamp is encoded in the UUID |
| Deterministic IDs | Version 5 | Same input always = same UUID |
| Distributed systems | Version 4 | No coordination needed between nodes |
| Content-based addressing | Version 5 | UUID derived from content itself |
Special UUIDs
NIL UUID
00000000-0000-0000-0000-000000000000
Max UUID
ffffffff-ffff-ffff-ffff-ffffffffffff
Code Examples
JavaScript (Browser/Node.js 15+)
// Native UUID v4
const uuid = crypto.randomUUID();
// Or using Web Crypto API
function generateUUID() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
);
}
Python
import uuid
# Version 4 (random)
id = uuid.uuid4()
# Version 1 (timestamp)
id = uuid.uuid1()
# Version 5 (SHA-1 namespace)
id = uuid.uuid5(uuid.NAMESPACE_DNS, 'example.com')
PostgreSQL
-- Enable extension
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- Generate v4 UUID
SELECT uuid_generate_v4();
-- Or use built-in (PostgreSQL 13+)
SELECT gen_random_uuid();
C# / .NET
// Generate new GUID
Guid newGuid = Guid.NewGuid();
// Parse from string
Guid parsed = Guid.Parse("550e8400-e29b-41d4-a716-446655440000");
// Format options
string formatted = newGuid.ToString("D"); // With hyphens
string compact = newGuid.ToString("N"); // No hyphens