What Is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit identifier standardized by RFC 4122, formatted as 32 hexadecimal digits in five groups separated by hyphens:
550e8400-e29b-41d4-a716-446655440000
^^^^^^^^ ^^^^ ^^^^ ^^^^ ^^^^^^^^^^^^
time time ver var node
UUIDs are designed to be unique across distributed systems without any central coordination โ no database sequence, no server round-trip needed.
UUID Versions Explained
| Version | Generation Method | Characteristics | Best For |
| UUID v1 | Timestamp + MAC address | Sortable by time; leaks MAC address | Time-ordered logging |
| UUID v4 | Fully random | Most common; no structure, no leakage | General purpose (default choice) |
| UUID v5 | Namespace + SHA-1 hash | Deterministic โ same input = same UUID | Content addressing, deduplication |
| UUID v7 | Unix timestamp (ms) + random | Time-sortable, database index-friendly | New projects needing ordered IDs |
How to Generate UUIDs Online
Use the tool.tl UUID Generator:
- Go to tool.tl/uuid-generator
- Choose a version (v4 for general use, v7 for database keys)
- Set the quantity (1 to 100)
- Click "Generate"
- Copy individual UUIDs or copy all at once
How Unlikely Is a UUID Collision?
UUID v4 has 122 bits of randomness. To put the collision probability in perspective:
- Generating 1 billion UUIDs gives a collision probability of roughly 1 in 5.3 ร 10ยฒโฐ
- At 1 billion UUIDs per second, it would take about 85 years to have a 50% chance of a single collision
In practice, UUID v4 collisions are not a real engineering concern.
UUID vs Other ID Schemes
| Scheme | Example | Pros | Cons |
| UUID v4 | 550e8400-... | No server needed, truly random | Unordered, worse index performance |
| UUID v7 | 018f7d3a-... | Time-ordered, index-friendly | Reveals generation time |
| Auto-increment int | 1, 2, 3โฆ | Simple, fastest index | Requires DB, fails in distributed systems |
| Snowflake ID | 7061564869888 | Ordered, high-throughput | Needs machine ID configuration |
| ULID | 01ARZ3NDEKTSโฆ | Ordered, shorter (Base32) | Less universal than UUID |
Generating UUIDs in Code
# Python (3.3+)
import uuid
print(uuid.uuid4()) # v4: random
print(uuid.uuid1()) # v1: time-based
// JavaScript / Node.js (18+)
import { randomUUID } from 'crypto';
console.log(randomUUID()); // v4
// Browser
console.log(crypto.randomUUID()); // v4
-- PostgreSQL
SELECT gen_random_uuid(); -- v4
-- MySQL 8.0+
SELECT UUID();
Frequently Asked Questions
What's the difference between UUID and GUID?
GUID (Globally Unique Identifier) is Microsoft's implementation of the UUID standard. They're functionally identical โ the terms are interchangeable. Microsoft tools often display GUIDs in uppercase and with curly braces: {550E8400-E29B-41D4-A716-446655440000}.
Should I use UUIDs as database primary keys?
UUID v4 works but causes index fragmentation in B-Tree indexes because inserts are random (not sequential). For new projects, prefer UUID v7 or ULID โ they're time-ordered, so new records always insert at the end of the index, matching auto-increment's performance characteristics while remaining globally unique.
Are UUIDs case-sensitive?
No. The hex digits in a UUID are case-insensitive (RFC 4122 recommends lowercase output). Always normalize to one case when storing or comparing to avoid subtle bugs.