Generate RFC4122 compliant UUIDs (v4)
Generate random UUIDs (Universally Unique Identifiers) instantly with our free online UUID generator. This tool helps developers create unique identifiers for databases, APIs, and distributed systems. Simply click generate to create random UUIDs in various formats.
UUID (Universally Unique Identifier) is a 128-bit number used to identify information in computer systems. This generator creates Version 4 UUIDs, which are randomly generated.
Format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
Total possible UUIDs: 2122 (approximately 5.3 × 1036)
Collision probability: Effectively zero for practical purposes
UUID (Universally Unique Identifier) is a 128-bit identifier standard (RFC 4122) that generates IDs guaranteed to be unique across space and time without central coordination. UUIDs are essential for distributed systems, database primary keys, and any scenario requiring unique identifiers without a central authority.
UUIDs contain 128 bits displayed as 32 hex digits in 8-4-4-4-12 format (e.g., 550e8400-e29b-41d4-a716-446655440000). Version 4 (random) uses cryptographically random numbers. Version 1 uses timestamp + MAC address. The version number and variant bits are embedded in specific positions.
UUID versions: v1 (timestamp + MAC, sortable but reveals info), v4 (random, most common), v5 (namespace + name hash, deterministic), v7 (timestamp + random, sortable). v4 UUIDs have: version "4" at position 13, variant bits (8, 9, a, or b) at position 17. Probability of v4 collision: 1 in 2^122, essentially zero in practice.
Generate unique IDs without auto-increment counters, enabling distributed inserts.
550e8400-e29b-41d4-a716-446655440000Each service generates IDs independently without coordination.
Unguessable session identifiers for web applications.
Unique names for uploads, avoiding collisions.
Track requests across microservices in logs.
// Browser (crypto API)
const uuid = crypto.randomUUID();
// "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d"
// Node.js (crypto module)
const { randomUUID } = require('crypto');
const uuid = randomUUID();
// Using uuid package (supports all versions)
const { v4: uuidv4, v5: uuidv5 } = require('uuid');
const random = uuidv4();
const deterministic = uuidv5('hello', uuidv5.URL);crypto.randomUUID() is built-in and uses secure random source. uuid package provides all versions.
import uuid
# Version 4 (random) - most common
id = uuid.uuid4()
# UUID('a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d')
# Version 1 (timestamp + MAC)
id = uuid.uuid1()
# Version 5 (namespace + name hash)
id = uuid.uuid5(uuid.NAMESPACE_URL, 'https://example.com')
# Convert to string (without dashes)
id_hex = uuid.uuid4().hex # 'a1b2c3d4e5f64a7b8c9d0e1f2a3b4c5d'Python's uuid module includes all versions. Use .hex for string without dashes.
-- Enable extension
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- Generate UUID
SELECT uuid_generate_v4();
-- As primary key
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
name VARCHAR(100)
);
-- PostgreSQL 14+: gen_random_uuid() built-in
CREATE TABLE items (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name VARCHAR(100)
);PostgreSQL supports UUID natively as a column type with built-in generation.
Use UUIDs when you need guaranteed-unique identifiers without central coordination: distributed databases, API resource IDs, session tokens, correlation IDs. Choose version based on needs: v4 for general use, v7 for sortable database keys.
Practically yes. UUIDv4 has 122 random bits, giving 5.3x10^36 possibilities. You'd need to generate 2.7 quintillion UUIDs to have a 50% chance of one collision. Random.org generates billions daily with no collisions ever recorded.