UUID version 4 generator
Random unique identifiers ready for databases and APIs.
Calculator inputs
Results
Enter your values and press “Calculate” to see the result.
In short
- What it calculates
- Random unique identifiers ready for databases and APIs.
- Formula used
Format: 8-4-4-4-12 hexadecimal characters- Example
- A v4 UUID looks like this:
UUID v4 generator
A UUID identifies a record uniquely without coordinating with any central server. That is why it appears in distributed systems, mobile sync and APIs.
Version 4 is built entirely from random bits.
How it works
Sixteen random bytes are generated and the bits marking version 4 and the standard variant are set, following the RFC 4122 specification.
Formula
Format: 8-4-4-4-12 hexadecimal characters
122 random bits out of 128 total
Worked example
A v4 UUID looks like this:
3f2b9c1a-7d4e-4a6b-9f01-2c8e5d7a4b3f
The fourth block always starts with 8, 9, a or b.
Explanation
The probability of repetition is negligible, not zero
A version 4 UUID has 122 random bits, giving on the order of five sextillion possible values. To reach a one per cent chance of collision you would have to generate about 2.6 quintillion identifiers. In practical terms it does not happen, but the guarantee is statistical rather than mathematical.
Why it is not always a good primary key
A random UUID inserts at scattered positions in the database index, fragmenting pages and degrading performance on large tables. It also takes sixteen bytes against four or eight for an integer. For tables with millions of rows and heavy insertion, that matters.
Ordered versions solve this
Variants embedding a timestamp at the start, such as version 7, generate identifiers that increase in order. They keep distributed uniqueness and behave well as a primary key, because insertions go to the end of the index.
When it genuinely pays off
When several systems generate records without coordinating: mobile apps working offline, distributed databases or merging data from different sources. There a UUID avoids collisions a central counter could not prevent.
Frequently asked questions
Can two UUIDs collide?
In theory yes, in practice no. You would need to generate billions per second for decades before the probability stopped being negligible.
Is it a good primary key?
Yes, though it takes more space than an integer and scatters indexes. For very large tables consider sortable variants such as UUID v7.
Can two UUIDs repeat?
Theoretically possible but practically impossible. You would need quintillions of generated identifiers to reach an appreciable collision probability.
Is it a good idea as a primary key?
Random ones fragment the index on large tables. Time-ordered versions such as v7 behave much better in that role.
Need to calculate something else?
These tools are often used alongside this calculator.
Passwords
Random passwords with calculated entropy, generated in your browser.
Hash
Cryptographic digest of a text in MD5, SHA-1, SHA-256 and CRC32.
Timestamp
Convert between Unix timestamps and readable UTC dates.
Base converter
Convert numbers between bases 2, 8, 10, 16, 32 and 36.
Base64
Turn text into Base64 and recover the original text.
Colours
Convert between colour formats and check contrast against white.