UUID Explained: What It Is and When to Use UUID v4
Applications need identifiers for records, requests, files, background jobs, and other objects. A database may assign an increasing integer to each row, but that approach is not always convenient when identifiers need to be created independently by different systems.
A UUID, or Universally Unique Identifier, is a 128-bit identifier designed to make accidental collisions extremely unlikely when generated correctly.
The iamnoobs UUID Generator creates UUID version 4 values and can generate multiple identifiers in one operation.
What does a UUID look like?
A UUID is commonly written as groups of hexadecimal characters separated by hyphens:
550e8400-e29b-41d4-a716-446655440000
The textual representation contains 32 hexadecimal digits and four hyphens. The underlying identifier is 16 bytes, or 128 bits.
UUIDs are standardized by the IETF. The current specification is RFC 9562, which describes multiple UUID versions and their formats.
What is UUID version 4?
UUIDv4 is generated from random or pseudorandom data. Some bits are reserved for the version and variant fields, leaving 122 bits for random data.
A UUIDv4 has a recognizable version marker in the third group. In the example above, the value begins with 4 in that group.
UUIDv4 is useful when an application needs an identifier that can be generated independently without asking one central service for the next sequence number.
Common uses of UUIDs
UUIDs are commonly used for:
- Database record identifiers.
- Correlation IDs for application requests.
- Identifiers for background jobs.
- Temporary object references.
- Resource IDs exchanged between services.
- File or upload identifiers.
A UUID is an identifier, not a description. Keep meaningful data such as a user's name, order status, or product category in separate fields.
UUID compared with an auto-incrementing integer
| Feature | UUID | Auto-incrementing integer |
|---|---|---|
| Generation | Can be generated independently | Usually allocated by a database or sequence |
| Size | 128 bits | Depends on the integer type |
| Guessability | UUIDv4 is random-looking, but should not be treated as an authorization secret | Sequential values are often easy to guess |
| Index locality | Random UUIDs can produce less sequential index insertion patterns | Increasing values are generally sequential |
| Distributed creation | Convenient across independent systems | Requires a coordinated sequence or allocation strategy |
Neither approach is best for every application. Consider storage size, database indexes, distributed workflows, data exposure, and operational requirements.
Generate UUIDs in JavaScript
Modern browsers and supported JavaScript runtimes provide crypto.randomUUID():
const id = crypto.randomUUID();
console.log(id);
// Example: 7f2b1b4e-6c6a-4d2d-a25f-1e2a3b4c5d6e
The example value is illustrative; each call generates a new UUID. The Web Crypto API's randomUUID method produces a version 4 UUID and is available in secure contexts in supported browsers.
If you need to create several identifiers, generate them independently and store each result with the record it identifies.
Generate multiple UUIDs with the online tool
- Open the iamnoobs UUID Generator.
- Enter how many identifiers you need. The tool accepts a count from 1 to 100.
- Select Generate UUIDs.
- Copy one identifier or copy the complete generated list.
- Store the identifiers where your application expects them.
The generator uses the browser's crypto.randomUUID() method. It does not require you to manually enter a prefix or choose a UUID version.
How likely is a UUID collision?
A collision occurs when two independently generated UUIDs have the same value.
UUIDv4 has 122 random bits. For independently generated values from a good random source, the approximate birthday-bound probability of at least one collision after generating n values is:
p ≈ n(n - 1) / (2 × 2^122)
This probability is extremely small for typical application workloads, but it is not mathematically zero. If uniqueness is a critical data-integrity requirement, enforce a unique constraint in the database and handle a conflict by generating another identifier.
UUIDs are not passwords or access tokens
A UUID may look random, but an identifier should not automatically be treated as an authentication secret.
For access control, use a purpose-built token design with appropriate expiration, revocation, authorization checks, and secure storage. Do not rely on a resource identifier alone to protect private data.
Common implementation considerations
Use a consistent representation
Choose whether your system stores UUIDs as native UUID values, 16-byte binary data, or text. Be consistent across database columns, APIs, logs, and application code.
Avoid changing case unnecessarily
Hexadecimal UUID strings may be represented in uppercase or lowercase. Comparisons should follow the UUID handling behavior of the language or database you use.
Keep database constraints
A generated identifier does not replace database constraints. A primary key or unique index remains the correct place to enforce uniqueness for stored records.
Think about index behavior
Random UUIDv4 values are not naturally sequential. In workloads with heavy database insertion, random primary keys can have different index and storage characteristics from sequential keys. Measure performance with your actual database and workload.
Frequently asked questions
Is UUID the same as GUID?
GUID is a term commonly used for the same general identifier family, especially in Microsoft ecosystems. UUID is the terminology used in the IETF specification.
Does UUIDv4 contain the date or machine address?
No. UUIDv4 is based on random or pseudorandom data, with the required version and variant bits. It is not designed to encode a creation timestamp or a network card address.
Can two UUIDs be identical?
Yes, a collision is theoretically possible. Correct UUIDv4 generation makes the probability extremely small, and database uniqueness constraints provide an additional safety check.
Further reading
Try it: iamnoobs UUID Generator