How to Generate UUIDs
March 22, 2026 · 6 min read
UUIDs (Universally Unique Identifiers) are 128-bit identifiers used everywhere in software — database primary keys, API request IDs, session tokens, distributed systems, and more. They're designed to be unique across time and space without a central authority.
In this guide, you'll learn what UUIDs are, the differences between UUID versions, and how to generate them in every major language and environment — or just use our free UUID generator.
What Is a UUID?
A UUID is a 128-bit number typically displayed as 32 hexadecimal digits in five groups separated by hyphens:
The format is 8-4-4-4-12 characters. With 2128 possible values (over 340 undecillion), the probability of generating two identical UUIDs is astronomically small — you'd need to generate 1 billion UUIDs per second for about 85 years to have a 50% chance of a single collision.
UUID Versions Explained
Not all UUIDs are created the same way. The version number is encoded in the UUID itself (the 13th character):
UUID v1 — Timestamp + MAC Address
Generated from the current timestamp and the machine's MAC address. Guarantees uniqueness but leaks information about when and where it was created.
Use when: You need time-sortable IDs and don't care about privacy.
UUID v4 — Random
Generated from random (or pseudo-random) numbers. The most commonly used version — simple, fast, and doesn't leak any information.
Use when: You need a unique ID and don't have special requirements. This is the default choice for most applications.
UUID v5 — Name-Based (SHA-1)
Generated by hashing a namespace UUID and a name with SHA-1. Always produces the same UUID for the same namespace + name combination — deterministic and reproducible.
Use when: You need the same UUID for the same input every time (e.g., generating an ID from a URL or email address).
UUID v7 — The Modern Choice
A newer standard (RFC 9562) that combines a Unix timestamp with random bits. Time-sortable like v1 but without leaking a MAC address. Increasingly the recommended default for databases.
Use when: You need database-friendly, time-sortable IDs (many new projects are adopting v7 over v4).
Generate UUID v1, v4, or bulk UUIDs with one click.
Open UUID GeneratorHow to Generate UUIDs
Method 1: Online Generator
The fastest way — use our UUID generator tool to create single or bulk UUIDs instantly. Supports v1 and v4 with one-click copy.
Method 2: JavaScript / Node.js
Modern browsers and Node.js have built-in UUID generation:
Method 3: Python
Method 4: Command Line
Method 5: SQL
UUID vs. Other ID Formats
- UUID vs. auto-increment — UUIDs don't require a central database to guarantee uniqueness. Auto-increment is simpler but creates bottlenecks in distributed systems.
- UUID vs. ULID — ULIDs are lexicographically sortable and use Crockford's Base32 (shorter). UUIDs are more widely supported.
- UUID vs. nanoid — nanoid generates shorter, URL-friendly IDs. UUIDs are the universal standard with broader library support.
- GUID vs. UUID — They're the same thing. "GUID" (Globally Unique Identifier) is Microsoft's term for UUID.
Best Practices
- Default to v4 for most use cases — it's simple, random, and widely supported.
- Use v7 for database primary keys — time-sortable UUIDs have better index performance than random v4.
- Never use UUIDs as secrets — v1 UUIDs are predictable, and even v4 UUIDs shouldn't replace proper tokens.
- Store as binary(16) in databases when possible — it's half the size of storing the string representation.
- Use lowercase — the RFC says UUIDs are case-insensitive, but lowercase is conventional.
Generate UUIDs Now
Need a UUID right now? Use the free UUID generator on UtilShed — generate single or bulk UUIDs with one click.
You might also find these tools useful:
- Hash Generator — generate MD5, SHA-1, SHA-256 hashes
- Password Generator — create secure random passwords
- Base64 Encoder/Decoder — encode and decode Base64 strings
- JSON Formatter — format and validate JSON data