Skip to main content
Skip to main content
DevelopmentJune 25, 20265 min read

UUID Versions Explained: A Complete Guide

Understanding UUID versions, their use cases, and how to generate them securely in the browser.

Generate unique identifiers with our UUID Tool. Create version 4 UUIDs instantly in your browser.

The ID Collision

Your database has a primary key violation. Two users have the same ID. How is that possible? You were using auto-increment integers.

Then you remember: you merged data from two different systems. Both started counting from 1. User #1 from System A conflicts with User #1 from System B.

This is why distributed systems use UUIDs. They are practically impossible to collide across all systems, all the time.

What is a UUID?

UUID stands for Universally Unique Identifier. It is a 128-bit number represented as 36 characters: 32 hexadecimal digits plus 4 hyphens.

A UUID looks like this: 550e8400-e29b-41d4-a716-446655440000. The format is 8-4-4-4-12 characters.

The chance of generating two identical UUIDs is astronomically low. You would need to generate billions of UUIDs per second for centuries to have a reasonable chance of a collision.

UUID Versions Explained

There are several UUID versions, each with different generation methods:

  • Version 1 - Based on timestamp and MAC address. Not recommended for privacy (reveals computer info).
  • Version 4 - Completely random. Most common and recommended for general use.
  • Version 5 - Based on a namespace and name. Same input always produces same UUID.
  • Version 7 - Newest version, combines timestamp and randomness. Good for database indexing.

When to Use UUIDs

UUIDs are ideal for:

  • Database primary keys - Especially in distributed systems
  • Session identifiers - Track user sessions securely
  • API keys - Generate unique access tokens
  • File names - Avoid conflicts when merging files from different sources
  • Transaction IDs - Track operations across microservices

UUID v7 in 2026: the new default

UUID v7 was standardized in RFC 9562 (May 2024) and has quickly become the default choice for new identifiers that need to be sortable and database-friendly.

Major databases now generate v7 natively (for example, PostgreSQL's uuidv7() in PostgreSQL 18), and popular identifier libraries ship v7 out of the box. Because v7 embeds a millisecond timestamp, values are time-ordered, which reduces B-tree index fragmentation under high insert volume.

Practical guidance: use v7 for primary keys and event IDs where ordering helps performance; use v4 when you need fully unpredictable random values (for example, tokens); avoid v1 for new work because it can leak the generating machine's MAC address.

When NOT to Use UUIDs

UUIDs are not always the best choice:

  • Sequential access patterns - UUIDs are random, causing index fragmentation
  • Very high write volumes - Random inserts are slower than sequential
  • Human-readable IDs - UUIDs are long and hard to remember
  • Small datasets - Auto-increment integers are simpler and more efficient

FAQ

Q.Are UUIDs really unique?

A.Practically yes. The probability of collision is so low (1 in 2^122 for v4) that you can treat them as unique for all practical purposes.

Q.Do UUIDs hurt database performance?

A.Random UUIDs (v4) can cause index fragmentation in B-trees. If performance is critical, use sequential UUIDs (v7) or ULIDs instead.

Q.Are UUIDs secure?

A.UUIDs are not designed for security. Do not use them as passwords or encryption keys. They are for identification, not authentication.

Q.Should I use UUID v7 or v4 in 2026?

A.For new database keys with high insert volume, UUID v7 is the practical default: it is time-ordered per RFC 9562, which reduces index fragmentation, and it is now supported natively in major databases and libraries. Choose v4 when you need purely random, unpredictable identifiers and ordering does not matter. Avoid v1 for new work because it can leak the generating machine's MAC address.

References

This article is based on industry standards and best practices from authoritative sources:

  • RFC 9562 - Universally Unique IDentifiers (UUIDs): https://www.rfc-editor.org/rfc/rfc9562

Generate UUIDs locally

Create UUID v1, v4, or v7 in your browser, one at a time or in batches.

Conclusion

Choosing the right UUID version is a schema decision with real performance impact. Generate v1, v4, or v7 locally with the UUID Generator.