UUID Generator
Generate random UUID v4 identifiers for databases, APIs and test data. Create one value at a time or a list of up to 100.
Your UUID
Version 4 · 128 bits · 36 characters—
Each value is generated separately, so duplicates in one list would be a genuine random coincidence rather than a re-used value.
UUID versions at a glance
| Version | Source of uniqueness | Typical use |
|---|---|---|
| v1 | Timestamp plus node identifier | Legacy time-based records |
| v3 | MD5 hash of a namespace and name | Stable name-derived keys |
| v4 | 122 random bits | General-purpose identifiers |
| v5 | SHA-1 hash of a namespace and name | Stable name-derived keys |
| v7 | Unix timestamp plus random bits | Time-sortable database keys |
This generator always produces version 4 values, the format used when no ordering or naming scheme is required.
A UUID is a number written in a very specific way
The identifier looks like a long string, but it is a 128-bit integer split into five groups. Understanding the grouping explains why some characters are fixed and why the length never changes.
Anatomy of a UUID string
The canonical form is 32 hexadecimal digits separated by hyphens in a 8-4-4-4-12 pattern, for a total of 36 characters. Hexadecimal is base 16, so each character carries four bits: 32 characters × 4 bits = 128 bits.
Two parts are not random in a version 4 value. The four bits at the start of the third group hold the version number 4, and the two most significant bits of the fourth group are fixed to 10 to mark the RFC variant. That leaves 122 bits of randomness, which is why a version 4 UUID is not a pure 128-bit random number.
What version 4 randomness actually means
A version 4 UUID draws its 122 random bits from a cryptographically secure generator. The browser API used here is crypto.randomUUID(), with a fallback that fills a buffer from crypto.getRandomValues() in older browsers. Both are designed for identifiers and keys, unlike Math.random(), which is not suitable for anything security-related.
The number of possible values is 2122, which is about 5.3 × 1036. Collisions are still possible in theory, because random selection can repeat, but the birthday bound puts the point where a collision becomes likely at roughly 261 values — about 2.3 × 1018. At that scale, a duplicate from a well-seeded generator is not a practical concern.
random bits = 128 − 4 (version) − 2 (variant) = 122
Uniqueness is probabilistic, not guaranteed. Libraries treat a UUID as unique because the probability of a repeat is negligible, not because a central authority hands out non-repeating numbers. If your system must reject duplicates absolutely, enforce a unique constraint in the database as well.
UUIDs vs auto-increment IDs
| Property | UUID v4 | Auto-increment integer |
|---|---|---|
| Size in text form | 36 characters | A few digits |
| Size in binary form | 16 bytes | 4 or 8 bytes |
| Generated where | Any client, without coordination | Usually the database |
| Ordering | None; sorted order is random | Monotonic |
| Information leak | Does not reveal record count | Reveals volume and growth |
| Index behavior | Random inserts fragment B-tree pages | Appends to the end of the index |
The trade-off is coordination versus locality. A UUID lets an offline client or a shard create a row without asking the database for a number, at the cost of a larger key and scattered writes. Sequential integers are compact and index-friendly but expose how many records exist and require a round trip to allocate.
Choosing a version for a new system
Version 4 remains the default when identifiers only need to be unique and unguessable-looking. Two newer versions solve specific problems:
- Version 7 starts with a 48-bit Unix timestamp in milliseconds, so values sort by creation time and insert near the end of a B-tree index. The remaining bits are random, which keeps them hard to predict.
- Version 5 derives a deterministic value from a namespace and a name. The same pair always produces the same UUID, which is useful for reproducible imports and idempotent jobs.
RFC 9562, published in 2024, defines versions 6, 7 and 8 and replaces the older RFC 4122 specification. Version 4 is unchanged by that revision, so values generated on this page remain valid under both documents.
Storing and passing UUIDs
A UUID is 16 bytes in binary but 36 characters as text. PostgreSQL has a native uuid type that stores the compact form; MySQL users often choose BINARY(16) and convert at the edges. Storing the text form is simpler to debug and easier to read in logs, at the cost of roughly double the space and a slower index.
Keep the hyphenated canonical form in URLs and API responses. Some systems accept 32 hex digits without hyphens, but mixing both forms in one table creates duplicate-looking keys that compare as different strings. Decide on lowercase or uppercase at the boundary and normalize on input.
Common UUID mistakes
- Treating a UUID as a secret. A random v4 value is hard to guess, but UUIDs appear in URLs, logs and analytics. Use a dedicated token with an expiry for access control.
- Sorting by v4. The order is random, so "newest first" requires a timestamp column, not the key.
- Using a weak fallback. A generator built on
Math.random()can repeat and is predictable. Prefer the platform's cryptographic source. - Assuming a fixed length everywhere. The canonical string is 36 characters, but braces,
urn:uuid:prefixes and hyphenless forms also exist. - Random keys in a hot index. Millions of random inserts cause page splits; consider v7 or an integer key when write throughput matters.
For test fixtures, generate values fresh instead of copying one from production. Real identifiers in fixtures can leak record counts and link test data back to live rows.
Related Developer & Security Tools
| Tool | What does it do? | Action |
|---|---|---|
| Base64 Encoder & Decoder | Encode text to Base64 or decode a Base64 string back to plain text. | Base64 Codec → |
| Hash Generator | Create MD5, SHA-1, SHA-256 and SHA-512 hashes from text. | Hash Maker → |
| UUID Generator | Generate random UUID v4 values, one or many at a time. | Current Page |
| Password Generator | Build strong random passwords with length and character options. | Password Maker → |
| Regex Tester | Test a regular expression against sample text and inspect the matches. | Regex Test → |
| JWT Decoder | Decode a JWT header and payload locally, without sending the token anywhere. | JWT Decode → |
Frequently Asked Questions
4 at the start of the third group, and the fourth group begins with a variant marker such as 8, 9, a or b.crypto.randomUUID() when the browser supports it, otherwise it fills a buffer with crypto.getRandomValues(). Values are created locally and never sent to a server.
Rate this Tool
Based on 0 user ratings.