Quick Answer: A UUID (Universally Unique Identifier) is a 128-bit ID written as 36 characters in the pattern 8-4-4-4-12, for example f47ac10b-58cc-4372-a567-0e02b2c3d479. Version 4 UUIDs are random, and version 7 UUIDs start with a timestamp so they sort by creation time. Both can be generated anywhere without a central server, with a negligible chance of duplicates. Use the free EasifyMe UUID Generator to create one or many UUIDs instantly.
Key Takeaways
- A UUID is 128 bits, shown as 32 hexadecimal characters plus 4 hyphens.
- Version 4 is fully random (122 random bits) and the most widely used.
- Version 7 puts a millisecond timestamp first, making IDs sortable and friendlier to database indexes.
- Duplicate v4 UUIDs are so unlikely that, for practical purposes, they are treated as unique.
- A GUID is Microsoft's name for the same thing.
What Is a UUID?
A UUID is an identifier designed to be unique across systems without anyone coordinating. Two servers on opposite sides of the world can each generate IDs, and the IDs will not clash. That makes UUIDs ideal for distributed systems, offline-first apps, database records, file names, API request IDs and session tokens.
UUIDs are standardised in RFC 9562, published in 2024, which replaced the earlier RFC 4122 and formally added versions 6, 7 and 8.
Anatomy of a UUID
f47ac10b-58cc-4372-a567-0e02b2c3d479
| | |
| | +-- variant: first character 8, 9, a or b
| +------- version: first character of 3rd group (4 = v4)
+------------ 8-4-4-4-12 hexadecimal groups
You can tell a UUID's version at a glance by the first character of the third group. In the example, it is 4, so this is a version 4 UUID.
UUID Versions Compared
|
Version |
How it is generated |
Sortable by time |
Typical use |
|
v1 |
Timestamp plus a node ID (often the MAC address) |
Not directly |
Legacy systems |
|
v3 / v5 |
Hash of a namespace and a name (MD5 / SHA-1) |
No |
Same input always gives the same UUID |
|
v4 |
Random |
No |
General purpose default |
|
v7 |
Unix timestamp in milliseconds plus random bits |
Yes |
Database primary keys, event logs |
v4 vs v7: Which Should You Use?
Use v4 when you just need a unique, unpredictable ID: API request IDs, file names, public-facing identifiers or test data.
Use v7 when the ID is a database primary key or anything you want to sort by creation time. Random v4 keys insert at random positions in a B-tree index, which can fragment the index and slow down writes on large tables. Because v7 IDs increase over time, new rows are added at the end of the index, much like an auto-increment number.
One caution: v7 reveals roughly when an ID was created. If that matters for privacy, use v4 for anything public.
How to Generate a UUID Online (Step by Step)
- Open the free UUID Generator.
- Choose the version you need and how many UUIDs to create.
- Pick a format if needed, such as uppercase or without hyphens.
- Generate the UUIDs.
- Copy a single UUID or the full list.
UUIDs are generated in your browser, so nothing is logged or stored on a server.
Try it free: Need test IDs for seed data or fixtures? Generate them in bulk with the free UUID Generator.
How to Generate a UUID in Code
// JavaScript (modern browsers and Node.js)
crypto.randomUUID();
# Python
import uuid
str(uuid.uuid4())
-- PostgreSQL (version 13 and later)
SELECT gen_random_uuid();
# Linux / macOS terminal
uuidgen
All of these produce version 4 UUIDs. Support for v7 is arriving in more languages and databases; where it is not built in, well-maintained libraries fill the gap.
Worked Examples
Example 1: Seeding a test database
A developer needs 500 user records with realistic IDs. Generating 500 v4 UUIDs in one go and pasting them into a seed file is faster than writing a script. The JSON seed file can be tidied with the JSON Formatter and checked with the JSON Validator before import.
Example 2: Tracing a request across services
Each incoming API request gets a v4 UUID as its request ID, passed along in a header to every downstream service. When something fails, searching the logs for that one ID shows the full journey.
Example 3: An orders table with v7 keys
An e-commerce database uses v7 UUIDs as primary keys. Orders can be created on several servers without coordination, yet the keys stay roughly in creation order, keeping inserts fast and making "newest orders" queries simple.
How Likely Is a UUID Collision?
With 122 random bits, a v4 UUID has about 5.3 × 10^36 possible values. You would need to generate roughly 2.71 quintillion (2.71 × 10^18) UUIDs to reach a 50% chance of a single duplicate. Real collisions come from bad random number generators, not from bad luck, so always use a cryptographically secure source such as crypto.randomUUID().
UUID vs Auto-Increment IDs
|
Factor |
Auto-increment (1, 2, 3…) |
UUID |
|
Size |
4–8 bytes |
16 bytes |
|
Generated where |
By the database |
Anywhere, even offline |
|
Guessable |
Yes: /users/124 hints at /users/125 |
v4 is not guessable |
|
Merging data from several databases |
Conflicts likely |
No conflicts |
|
Human-friendly |
Yes |
No |
Common Mistakes to Avoid
- Treating UUIDs as secrets. A UUID is unique, not a password. Use proper tokens for authentication.
- Using weak randomness. Math.random()-based generators can collide. Use a crypto-secure function.
- Storing UUIDs as text in large tables. A native UUID or 16-byte binary column is smaller and faster.
- Mixing formats. Pick one case and hyphen style so comparisons work.
Related Developer Tools
When you need to pass IDs or binary data through text-only channels, the Base64 Encoder and Base64 Decoder help; our guide on what Base64 encoding is explains when to use it. Find more utilities in the developer tools hub.
Frequently Asked Questions
What is a UUID used for?
UUIDs give records, files, requests and objects unique IDs without a central authority. They are common as database keys, API request IDs, file names and identifiers in distributed systems.
What is the difference between UUID v4 and v7?
UUID v4 is entirely random. UUID v7 starts with a millisecond timestamp followed by random bits, so v7 IDs sort by creation time and work better as database primary keys.
Are UUIDs really unique?
In practice, yes. You would need to generate about 2.71 quintillion v4 UUIDs for a 50% chance of one duplicate, provided a secure random generator is used.
Is a GUID the same as a UUID?
Yes. GUID (Globally Unique Identifier) is the term Microsoft uses. GUIDs follow the same 128-bit format as UUIDs.
Can I generate multiple UUIDs at once?
Yes. The EasifyMe UUID Generator can create a batch of UUIDs in one click, ready to copy into your code or spreadsheet.
Can a UUID be made shorter?
Yes. A UUID is 16 bytes, so encoding those bytes in URL-safe Base64 gives a 22-character string instead of 36. Convert it back before storing it in a UUID column.