Generate cryptographically random UUIDs (version 4) instantly.
UUID (Universally Unique Identifier) is a 128-bit number used to uniquely identify information. Version 4 UUIDs are generated randomly and have extremely low collision probability. Perfect for database IDs, session tokens, or any system requiring unique identifiers.
A UUID (Universally Unique Identifier) is a 128-bit identifier that's virtually guaranteed to be unique across space and time.
Format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is hexadecimal (0-9, a-f).
The chance of generating duplicate UUID v4 is approximately 1 in 2ยนยฒยฒ (340 undecillion). You'd need to generate a billion UUIDs per second for 100 years to have a 50% chance of a single collision. For practical purposes: UUIDs are unique.
Generated from timestamp + MAC address. Predictable and reveals creation time/location. Not recommended for security-sensitive applications.
Generated from random/pseudo-random numbers. Most common and recommended. No predictable patterns, safe for security tokens.
Generated from namespace + name (deterministic). Same input always produces same UUID. Useful for reproducible identifiers.
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name VARCHAR(100),
created_at TIMESTAMP DEFAULT NOW()
);
INSERT INTO users (name) VALUES ('John Doe');
-- ID automatically generated:
-- 550e8400-e29b-41d4-a716-446655440000
// Original: profile.jpg
// Uploaded as: a3f4b8c2-1234-4567-89ab-0123456789ab.jpg
// Prevents overwrites and name conflicts
Theoretically yes, practically no. The collision probability is so low (1 in 10ยณโธ) that you'll never encounter it in real-world usage. You're more likely to win the lottery 5 times in a row than generate duplicate UUIDs.
UUIDs pros: Global uniqueness, no coordination needed, works in distributed systems, harder to guess.
Auto-increment pros: Smaller size (4-8 bytes vs 16 bytes), faster indexing, sequential = better for B-tree indexes.
Use UUIDs when: distributed systems, security matters, need offline generation. Otherwise auto-increment is fine.
Convention is lowercase, but UUIDs are case-insensitive. Most databases and systems treat them the same. Stick with lowercase for consistency (RFC 4122 standard uses lowercase in examples).
Yes! The hyphens are just for readability. Some systems store UUIDs without hyphens as 32-character hex strings.
Both 550e8400-e29b-41d4-a716-446655440000 and 550e8400e29b41d4a716446655440000 represent the same UUID.
// Modern browsers support crypto.randomUUID()
const uuid = crypto.randomUUID();
console.log(uuid);
// "a3f4b8c2-1234-4567-89ab-0123456789ab"
import uuid
# Generate UUID v4
new_uuid = uuid.uuid4()
print(str(new_uuid))
# "550e8400-e29b-41d4-a716-446655440000"
-- Enable UUID extension
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- Generate UUID
SELECT uuid_generate_v4();
-- "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11"