CalquioCalquio

Search

Search for calculators and tools

UUID Generator

Generate random UUIDs (v1, v4, v7). Create unique identifiers for your applications.

Code Examples
// Native crypto API (UUID v4)
const uuid = crypto.randomUUID();
// Using uuid library
// npm install uuid
import { v4 as uuidv4, v1 as uuidv1 } from 'uuid';
const id = uuidv4(); // Random
const id1 = uuidv1(); // Time-based

You May Also Like

What is a UUID?

A UUID (Universally Unique Identifier) is like a digital fingerprint - a 128-bit number that's virtually guaranteed to be unique across all computers, all time, everywhere in the universe.

It looks like this: 550e8400-e29b-41d4-a716-446655440000

Why do we need them?

  • Create unique IDs without a central authority
  • Merge databases without ID conflicts
  • Generate IDs offline that stay unique when synced
  • Track objects across distributed systems

Think of UUIDs as license plates for data - each one is unique, and you don't need to ask anyone's permission to create one.

UUID Versions Explained

VersionBased OnBest For
v1Timestamp + MAC addressTime-ordered records
v4Random numbersMost common, general use
v5Namespace + name (SHA-1)Reproducible IDs from names
v7Timestamp + random (new!)Database-friendly, sortable

Version 4 (Random) - Most Popular

f47ac10b-58cc-4372-a567-0e02b2c3d479
         โ†‘
    "4" indicates version 4

Uses cryptographically secure random numbers. The chance of collision is astronomically low.

Version 1 (Time-based) Encodes the current timestamp and your computer's MAC address. Useful when you need to know when a UUID was created.

Version 7 (Newest, 2022) Combines timestamp with randomness. Perfect for databases because UUIDs are sortable by creation time!

How Unique Are UUIDs Really?

๐ŸŽฒ The Math Behind Uniqueness

UUID v4 has 122 random bits, giving us 2^122 possible combinations: 5,316,911,983,139,663,491,615,228,241,121,400,000 unique UUIDs

To have a 50% chance of collision:

  • Generate 2.71 ร— 10^18 UUIDs
  • At 1 billion UUIDs per second, this takes 86 years!

Real-world perspective:

  • If every person on Earth generated 1 UUID per second
  • For 100 years straight
  • The collision probability would still be less than 0.00000001%

For all practical purposes, you can treat UUID v4 as unique. No coordination needed, no database lookups - just generate and use!

Anatomy of a UUID

550e8400-e29b-41d4-a716-446655440000
โ”‚        โ”‚    โ”‚    โ”‚    โ”‚
โ”‚        โ”‚    โ”‚    โ”‚    โ””โ”€โ”€ Node (48 bits)
โ”‚        โ”‚    โ”‚    โ””โ”€โ”€ Clock sequence (14 bits)  
โ”‚        โ”‚    โ””โ”€โ”€ Version (4 bits) + Time high
โ”‚        โ””โ”€โ”€ Time mid (16 bits)
โ””โ”€โ”€ Time low (32 bits)

The 8-4-4-4-12 Format

  • 32 hex characters
  • 5 groups separated by hyphens
  • 128 bits total (4 bits per hex character)

Version Indicator The 13th character tells you the version:

  • 1 = Time-based (v1)
  • 4 = Random (v4)
  • 7 = Unix timestamp (v7)

When to Use UUIDs

โœ… Perfect for:

  • Database primary keys (especially distributed systems)
  • API resource identifiers
  • Session tokens
  • File names for uploads
  • Tracking IDs across microservices

โš ๏ธ Consider alternatives when:

  • You need human-readable IDs (use short codes instead)
  • Storage space is critical (UUIDs are 16 bytes)
  • You need strictly sequential IDs (use auto-increment)
  • URL aesthetics matter (UUIDs are long and ugly)

๐Ÿ’ก Pro Tips:

  • Store as binary (16 bytes) not string (36 bytes) in databases
  • Use UUID v7 for better database index performance
  • Never expose UUIDs that could leak timing information

UUID vs Alternatives

ID TypeLengthSortableCollision-FreeExample
UUID v436 charsโŒPracticallyf47ac10b-58cc-...
UUID v736 charsโœ…Practically018e4c8b-...
ULID26 charsโœ…Practically01ARZ3NDEKTSV4...
NanoID21 charsโŒConfigurableV1StGXR8_Z5jdHi6B
Snowflake19 digitsโœ…Guaranteed*1541815603606036480

*Snowflake IDs require coordination (machine ID assignment)

Security Note: Don't use UUIDs as secret tokens! They're unique but not necessarily unpredictable (especially v1). For auth tokens, use cryptographically secure random strings.