webtools

UUID Generator

Private: generated on your device, never sent anywhere

Generated

                

Generate one UUID or a thousand, as random v4 or time ordered v7, in whichever format your code wants. There is also a checker: paste an ID and find out whether it is valid and which version it is.

About UUIDs

A UUID is a 128 bit identifier written as 32 hex characters in five groups. The point of it is that anything can mint one at any time, with no central counter and no coordination, and still be safe in the assumption that nobody else will ever produce the same value. That is what makes them useful for database keys, file names, request IDs and anything generated offline or on several machines at once.

Version 4 is 122 random bits, which is the version almost everyone means when they say UUID. Version 7 is newer: it starts with a millisecond timestamp and fills the rest with randomness, so the IDs sort by the time they were created. That single property makes a real difference to database write performance, because inserts land at the end of the index instead of scattering across it.

The format is cosmetic; the storage is not. Uppercase, lowercase, braces and the hyphens all carry the same 128 bits, and the standard asks for lowercase on the way out while requiring that comparison ignore case, which is why the other forms are offered here without pretending they are different IDs. Storage is where the choice costs something: written as text a UUID is 36 characters, against the 16 bytes it actually is, so a table keyed on a text column carries more than twice the key in its primary index and in every foreign key pointing at it. Postgres has a native uuid type and MySQL has BINARY(16), and picking one is much cheaper before the table is large than after.

One thing a UUID is often asked to do and should not. A v4 from this page carries 122 bits out of your browser's cryptographic generator, which is ample entropy for a bearer token, but an identifier and a secret want opposite things: an ID gets logged, put in URLs and quoted in support tickets. If you need a secret, the password generator gives you the same quality of randomness in a shorter string that nobody will mistake for a record ID.

How to generate a UUID

  1. Pick the Version: v4 for a plain random ID, v7 if the order matters.
  2. Pick a Format: lowercase is standard, but some systems want uppercase, no hyphens or braces.
  3. Set How many, up to a thousand, for seeding test data.
  4. Press Copy to take the whole list, one per line.
  5. Paste any ID into Check a UUID to confirm it is valid and see which version it is.

Common questions about UUIDs

Are these generated on a server?

No. They come from your browser's own cryptographic random number generator, on this page. Nothing is sent, logged or saved, and the page keeps working with your connection switched off. Reload and you get a completely different set.

Can two UUIDs ever collide?

In theory yes, in practice no. A v4 UUID has 122 random bits, so you would need to generate about 2.7 quintillion of them before there was even a one in a billion chance of a repeat. The real risk is not chance but a broken generator, which is why this uses the cryptographic source rather than Math.random.

Should I use v4 or v7?

Use v7 for primary keys in a database, because sorted inserts keep the index tidy and you get a rough creation time for free. Use v4 anywhere the value is public or guessing order would leak something, such as a share link or an unauthenticated lookup, since a v7 ID tells the reader when it was made.

Why does my UUID have a 4 in the middle?

That character is the version. The first character of the third group says which scheme made the ID, and a few bits at the start of the fourth group mark the variant. They are fixed rather than random, which is why a v4 UUID has 122 random bits rather than 128.

What is the nil UUID?

All zeroes. It is a valid UUID reserved to mean "none", in the way a null would, and it is handy for a placeholder in a fixture or a migration. The checker above recognises it and says so, because seeing a row of zeroes in production data usually means something failed to set a value.

Next

Related tools

All Dev tools