Developer3 min read
UUID Generator - What Is a UUID and When to Use It
UUIDs (Universally Unique Identifiers) are 128-bit identifiers used everywhere in software - database primary keys, API resource IDs, session tokens, and distributed systems. If you have seen a string like 550e8400-e29b-41d4-a716-446655440000, that is a UUID.
What Makes a UUID Unique?
A UUID has 128 bits (32 hex characters in 5 groups). The chance of a random collision is about 1 in 5.3 x 10^36 - essentially zero for any practical application. You can generate billions of UUIDs per second and never get a duplicate.
UUID Versions Explained
- v1 - timestamp + MAC address. Leaks the machine identity. Rarely used today.
- v3 - MD5 hash of a namespace + name. Deterministic (same input = same UUID).
- v4 - random. The most common version. Used by default in most generators. 122 random bits.
- v5 - SHA-1 hash of a namespace + name. Like v3 but more secure.
- v7 - timestamp-ordered + random. New standard (RFC 9562, 2024). Sortable by time. Recommended for new systems.
When to Use UUIDs
- Database primary keys - avoid sequence guessing and collisions across shards
- API resource IDs -
/api/users/550e8400-...instead of sequential/api/users/42 - Distributed systems - generate IDs without a central coordinator
- Session tokens - unpredictable, hard to guess
- File names - avoid collisions when multiple users upload
photo.jpg
UUID v4 vs. v7 - Which to Choose?
- v4 - fully random, no ordering. Good for general use.
- v7 - time-ordered prefix + random suffix. Better for databases (sequential inserts = less index fragmentation). The modern choice for new projects.
Free Online UUID Generator
Use SnapSum UUID Generator to generate UUIDs in your browser - no network needed after page load, no account, no tracking.
- Generate v4, v5, and v7 UUIDs
- Batch generate (1-100 at once)
- One-click copy individual or all UUIDs
- Works offline after initial page load
Step-by-Step: Generate UUIDs
- Open UUID Generator.
- Select UUID version (v4, v5, or v7).
- Choose how many to generate (1-100).
- Click "Generate" and copy your UUIDs.
UUIDs vs. Sequential IDs
| Feature | Sequential ID | UUID |
|---|---|---|
| Guessable | Yes (/user/42) | No |
| Distributed-safe | No (needs central DB) | Yes |
| DB index perf | Excellent | Good (v7 better) |
| Storage size | 4-8 bytes | 16 bytes (128-bit) |