What is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit value used to uniquely identify objects in software systems. Version 4 UUIDs are randomly generated and have a collision probability so low it is considered negligible — there are approximately 5.3 × 10³⁶ possible v4 UUIDs.
UUID Format
Common Uses
- Primary keys in databases (alternative to auto-increment integers)
- Unique identifiers for API requests, sessions, and events
- File naming to avoid collisions
- Distributed systems where a central counter isn't practical
Frequently Asked Questions
Are these UUIDs truly unique?
For all practical purposes, yes. The probability of generating two identical v4 UUIDs is approximately 1 in 5.3 undecillion. You would need to generate about 1 billion UUIDs per second for 85 years to have a 50% chance of a single collision.
Is it safe to use these as database keys?
Yes, UUID v4 is widely used as a database primary key. The main trade-off vs. sequential integers is index fragmentation in B-tree indexes. UUID v7 (time-ordered) solves this but isn't yet as widely supported.
What does UUID stand for, and what is UUID v4?
UUID stands for Universally Unique Identifier. It is a 128-bit identifier standardized by RFC 4122. Version 4 (v4) is randomly generated — 122 of the 128 bits are random, with 6 bits reserved for version and variant markers. The format is always 8-4-4-4-12 hexadecimal characters, for example: 550e8400-e29b-41d4-a716-446655440000.
Can I use a UUID as a URL slug?
Technically yes, but it makes for ugly, unmemorable URLs (e.g., /products/550e8400-e29b-41d4-a716-446655440000). A better pattern is to use a UUID as the internal database key while generating a human-readable slug (e.g., /products/red-running-shoes) for the public URL, mapping the slug to the UUID record in your database.