What Is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit identifier that's practically guaranteed to be unique across all systems, all time. They look like this: 550e8400-e29b-41d4-a716-446655440000. UUIDs are used as database primary keys, API identifiers, session tokens, and anywhere you need a unique ID without coordinating with a central authority.
UUID v4: Fully Random
UUID v4 generates identifiers using 122 bits of random data. This is the most commonly used version and what most people mean when they say "UUID."
- Pros: Simple, widely supported, no metadata leakage, extremely low collision probability
- Cons: Not sortable by creation time, poor database index performance due to randomness
- Use when: You need a simple unique ID and don't care about ordering
UUID v7: Time-Sortable
UUID v7 is the modern alternative. It encodes a Unix timestamp in the first 48 bits, followed by random data. This means v7 UUIDs are naturally sorted by creation time.
- Pros: Time-sortable, excellent database index performance (sequential inserts), still globally unique
- Cons: Leaks creation time (usually not a problem), newer standard with less library support
- Use when: Database primary keys, event IDs, anything that benefits from chronological ordering
Why UUID v7 Is Better for Databases
Random UUID v4 values scatter inserts across B-tree indexes, causing page splits and fragmentation. UUID v7's sequential nature means new records are always appended to the end of the index, similar to auto-incrementing integers. This can improve write performance by 2-10x on large tables.
Generate UUIDs Instantly
Use our free UUID Generator to create v4 UUIDs right in your browser. Need to generate them in bulk? The tool supports batch generation of up to hundreds of UUIDs at once.
For other identifier needs, check out our Random Token Generator for API keys, or the API Key Generator for formatted keys.
More Developer Tools
- JSON Formatter — Pretty-print and validate JSON
- JWT Decoder — Decode and inspect JSON Web Tokens
- Base64 Encoder — Encode strings and files
- Timestamp Converter — Convert between Unix timestamps and dates
- Regex Tester — Test regular expressions with live matching
Explore all Developer Tools on ToolHaven.