Order numbers, file names, API keys and database records often carry long identifiers like 550e8400-e29b-41d4-a716-446655440000. These are UUIDs. So what is a UUID, why not just number things 1, 2, 3, and which version should you use? This guide explains the format, the versions and the practical trade-offs for developers.
The definition
A UUID (Universally Unique Identifier) is a 128-bit value designed to be unique without any central system handing out numbers. Microsoft calls the same thing a GUID (Globally Unique Identifier).
It is written as 32 hexadecimal characters in five groups separated by hyphens – the 8-4-4-4-12 format, 36 characters in total:
550e8400-e29b-41d4-a716-446655440000
The first digit of the third group shows the version – here "4" means version 4.
Why not use 1, 2, 3?
Auto-incrementing numbers are simple, but they have drawbacks:
- They reveal information. Order #1042 tells competitors roughly how many orders you have, and invoice /1043 invites people to guess other URLs.
- They need a central counter. Two servers, offline apps or merged databases can easily create the same number.
- They clash when merging data from different systems.
UUIDs can be generated anywhere – on a phone, a server or in the browser – with practically no chance of duplicates.
The main versions
- UUID v4 – random. 122 bits are random. The most widely used version for general IDs.
- UUID v7 – time-ordered. Standardised in 2024 (RFC 9562). The first part encodes a Unix timestamp in milliseconds and the rest is random, so new IDs sort roughly in creation order.
- UUID v1 – time and machine based. Older; can leak the creating machine's network address.
- UUID v5 – name-based. The same input name always produces the same UUID, using a hash.
How unique are they?
For v4, there are about 5.3 × 10³⁶ possible values. You would need to generate billions of UUIDs every second for many years before having a meaningful chance of a single collision. For practical purposes, they are unique.
UUIDs in databases
Using a UUID as a primary key has trade-offs:
- Pros: IDs can be created before saving, data merges easily, and URLs do not reveal record counts.
- Cons: they are larger than integers (16 bytes stored as binary, 36 as text), and random v4 values scatter inserts across the index, which can slow very large tables.
UUID v7 fixes most of the index problem because it is time-ordered. Many modern frameworks, including recent versions of Laravel, now default to ordered UUIDs for this reason. If you store them as text, use a fixed CHAR(36) column; binary storage is more compact.
UUIDs are not secrets
Random UUIDs are hard to guess, but they are not designed as passwords or security tokens. For secrets such as API keys and password reset links, use a cryptographically secure random token of sufficient length – the Password Generator can create one – and see what is a hash function for how secrets should be stored.
Generate UUIDs instantly
The free UUID Generator creates version 4 UUIDs in bulk, in upper or lower case, with or without hyphens, using your browser's secure random generator.
Other developer tools: Random Number Generator, Hash Generator and Unix Timestamp Converter – see what is a Unix timestamp.
Frequently asked questions
Is a GUID the same as a UUID? Yes, in practice. GUID is Microsoft's name for the same 128-bit identifier.
Are UUIDs case-sensitive? No. Upper and lower case represent the same value, though lower case is the standard output.
Can I shorten a UUID? You can encode it more compactly (for example in Base64), but keep the standard format when sharing between systems.
Summary
So, what is a UUID? A 128-bit identifier written in an 8-4-4-4-12 format that can be generated anywhere with practically no risk of duplicates. Use v4 for general random IDs and v7 when you want IDs that sort by time, especially as database keys. Generate as many as you need with the free UUID Generator.