UUID Generator: What Is a UUID and How to Generate One

Tools โ€” views

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

VersionGeneration MethodCharacteristicsBest For
UUID v1Timestamp + MAC addressSortable by time; leaks MAC addressTime-ordered logging
UUID v4Fully randomMost common; no structure, no leakageGeneral purpose (default choice)
UUID v5Namespace + SHA-1 hashDeterministic โ€” same input = same UUIDContent addressing, deduplication
UUID v7Unix timestamp (ms) + randomTime-sortable, database index-friendlyNew projects needing ordered IDs

How to Generate UUIDs Online

Use the tool.tl UUID Generator:

  1. Go to tool.tl/uuid-generator
  2. Choose a version (v4 for general use, v7 for database keys)
  3. Set the quantity (1 to 100)
  4. Click "Generate"
  5. 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

SchemeExampleProsCons
UUID v4550e8400-...No server needed, truly randomUnordered, worse index performance
UUID v7018f7d3a-...Time-ordered, index-friendlyReveals generation time
Auto-increment int1, 2, 3โ€ฆSimple, fastest indexRequires DB, fails in distributed systems
Snowflake ID7061564869888Ordered, high-throughputNeeds machine ID configuration
ULID01ARZ3NDEKTSโ€ฆ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.