Every application eventually faces the same small problem: two parts of the system need to create an identifier at the same moment, and neither can ask the other what has already been used. A single database can hand out the next integer. Two application servers, a phone working offline, or a second database being merged in later cannot. UUID version 4 became the default answer because it removes the question entirely: the identifier is random, so nobody has to coordinate anything.

This guide explains why v4 won that default position, what its randomness does and does not give you, and where its trade-offs make a different scheme the better choice. When you need values, the free UUID Generator on Ovatly creates version 4 UUIDs locally in your browser.

Contents

  • Quick answer
  • The problem v4 removes: coordination
  • The arithmetic that makes randomness enough
  • Nothing leaks: no clock, no hardware address
  • How to generate v4 UUIDs, step by step
  • Worked example: what the pattern proves
  • Limitations and trade-offs
  • Common mistakes
  • FAQs
  • Conclusion

Quick answer

Version 4 is the default because it needs nothing but randomness. There is no central counter to ask, no clock to trust and no machine address embedded in the value. Each generator draws from a cryptographic random source, and with 122 random bits per value the chance of two generators producing the same UUID is so small that the industry treats collisions as a non-event. The UUID Generator creates v4 UUIDs from 1 to 100 at a time, in the canonical lowercase hyphenated form, and stores nothing.

The problem v4 removes: coordination

Sequential identifiers work only while one authority hands them out. The moment identifiers are created in more than one place, a counter becomes a bottleneck or a collision source. Offline mobile apps, sharded services, event producers and database merges all hit this wall: each side mints identifiers alone and trusts they will not clash when the data meets.

Random UUIDs move the trust from coordination to arithmetic. Any component that can produce good random numbers can mint identifiers that the whole system accepts, with no registry to consult and no round trip to a central service first. That independence is why UUIDs are the standard way to give database rows, files, sessions and API resources an identifier that is practically guaranteed unique without asking a central server for permission.

A value created in a browser, on a phone or in a batch job is valid everywhere else, written in the same canonical lowercase form with hyphens that most databases and APIs expect, so it pastes from one system into another without translation.

The arithmetic that makes randomness enough

A version 4 UUID is a 128-bit value in which 122 bits are chosen at random. The space that leaves is so large that independent generators effectively never repeat a value. The comparison that makes the point: you would need to generate billions of UUIDs per second for years to expect one accidental collision. Uniqueness stops being a property you enforce with locks and checks and becomes a property of the numbers themselves.

This is the part teams sometimes resist, because it feels like trusting luck. It is not luck; it is the same reasoning that makes a long random password safe. Once the space is large enough and the random source is sound, a clash becomes less likely than ordinary hardware failure. The generator uses your browser's cryptographic random source, which is the sound-source half of that bargain.

Nothing leaks: no clock, no hardware address

Other identifier schemes encode facts about their origin. Time-based values reveal when a record was created. Older UUID versions could embed the address of the machine that made them. Sometimes that is information you did not mean to publish: creation timestamps can expose signup order or record volume, and hardware addresses identify equipment.

A version 4 UUID encodes nothing but its own markers. Looking at one, you can tell it is version 4 and nothing else: not when it was made, not where, not what came before or after it. For public-facing identifiers, such as the ID in a URL for an invoice, a shared file or an API resource, that blankness is a feature. The value identifies the resource without narrating its history, and it cannot be used to guess the identifier of the record created just before it.

How to generate v4 UUIDs, step by step

  1. Open the UUID Generator and choose how many UUIDs you need, from 1 to 100.
  2. Press Generate UUIDs. The values are created with your browser's cryptographic random source, so batches of 100 are instant.
  3. Copy one value, or use Copy all to take the whole list, one per line.
  4. Generate again whenever you need a fresh batch. Values are never repeated or stored, so each press gives you new identifiers.

Worked example: what the pattern proves

Every result from the generator follows the pattern xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx. Read a generated value against it and you can confirm what you are holding. The first digit of the third group is always 4: the version marker, proving the value is the random kind rather than a time-based one. The first digit of the fourth group, the y position, is one of 8, 9, a or b: the variant marker. The other 122 bits are random.

Any system receiving a UUID can tell how it was made without asking the sender, and a database can hold v4 values alongside other versions without ambiguity. The form is canonical too: lowercase with hyphens, which is what most databases and APIs expect, so generated values paste straight into seed scripts, fixture files and API requests without reformatting.

Limitations and trade-offs

The trade-offs are real, and naming them is part of why v4 stays the default only where it fits.

First, random values carry no ordering information. Two UUIDs minted a second apart look unrelated, so a list sorted by identifier is not sorted by creation time. If you need time-ordered identifiers, for example so that database inserts sort naturally by creation time, look at UUID v7 in a dedicated library instead. This generator creates version 4 only.

Second, a UUID is larger than a sequential integer: a 128-bit value written as 36 characters with hyphens, against a handful of digits for a counter. In URLs, logs and indexes that size is visible, and on very large tables it is a legitimate design consideration.

Third, a UUID is an identifier, not a credential. It is unguessable, which makes it a good identifier for a resource, but for API keys or passwords prefer a longer password from this site's Password Generator, which gives you more entropy and control over the character set.

Common mistakes

  • Assuming v4 is the only version. Other versions exist for other jobs. V4 is the default because randomness fits most cases, not because the alternatives are wrong.
  • Sorting by a v4 UUID and expecting time order. Random values have no sequence. Store a separate timestamp column if you need ordering.
  • Using a UUID as a secret. Unguessable is not the same as a credential. Keep keys and passwords in tools built for them.
  • Checking each new UUID against a database for duplicates. With 122 random bits, that check is wasted work; uniqueness is the design, not a hope.
  • Reformatting values. Uppercase or hyphen-free copies can mismatch what a database stored. Keep the canonical lowercase hyphenated form the tool gives you.

FAQs

Why is version 4 the most commonly used UUID version? It needs only a good random source. There is no counter to coordinate, no clock to synchronise and no machine address to embed, so any component can mint identifiers the whole system accepts.

Does a version 4 UUID contain a timestamp or a machine address? No. Apart from the fixed version and variant markers, every bit is random. Nothing in the value reveals when it was created, where it was created, or what was generated before or after it.

Are version 4 UUIDs guaranteed unique? Version 4 UUIDs carry 122 random bits. The chance of an accidental duplicate is so small that the whole industry treats them as unique; you would need to generate billions per second for years to expect one collision.

Can I use a version 4 UUID as an API key or password? A UUID works as an unguessable identifier, but for credentials prefer a longer password from this site's Password Generator, which gives you more entropy and control over the character set.

What if I need identifiers that sort by creation time? Version 4 values are random, so they carry no ordering information. If you need time-ordered identifiers, look at UUID v7 in a dedicated library instead. The generator on this page creates version 4 only.

Conclusion

Version 4 is the default because it asks for the least: a good random source and nothing else. No counter, no clock, no hardware identity, and a collision risk the industry treats as zero. The UUID Generator gives you those values singly or in batches of up to 100, generated locally and stored nowhere. The natural next question is where to use them, and the most common answer is the database itself, which the companion guide weighs up in detail.

Related guide: How to Use UUIDs as Database Primary Keys: Pros and Cons.

More tools for this kind of work live in the Developer Tools archive.