Spunk Autos

Websites and web tools

UUID Generators: A Power User's Guide

A UUID is a 128-bit identifier written as 36 characters, such as a booking reference, an inventory record key or an upload file name. Online generators make one in a click, but power users need to know which version to pick, how safe random UUIDs really are, and how to store them without wasting space.

The format

A UUID is written as 32 hexadecimal digits in five groups separated by hyphens, in the pattern 8-4-4-4-12. One digit shows the version and another shows the variant. The formats are defined in RFC 9562, which replaced the older RFC 4122.

Which version to use

VersionBuilt fromSortable by timeGood for
1Timestamp plus a node identifier, often derived from a network addressNot in plain text orderLegacy systems; can leak the machine and creation time
4122 random bitsNoGeneral IDs where order does not matter
5Hash of a namespace and a nameNoThe same input must always give the same ID
7Millisecond Unix timestamp plus random bitsYesDatabase primary keys and logs where insert order helps

For new work, version 4 and version 7 cover nearly every case. Choose 7 when IDs will be a database index, because time-ordered values keep new rows near each other and reduce index fragmentation.

How likely is a collision?

A version 4 UUID has 122 random bits, or about 5.3 times 10 to the power 36 possible values. With the birthday approximation, the chance of any collision among n IDs is roughly n squared divided by 2 times 2 to the power 122.

Storage choices

Stored as text, a UUID takes 36 characters. Stored as binary, it takes 16 bytes, so text uses 2.25 times as much space, and indexes grow to match. Many databases have a native UUID type that stores 16 bytes and still displays the familiar text form; use it when available.

Power-user tips

  • Generate IDs in your own code with a well-known library, not by copying from a website into production data.
  • Check that the library uses a cryptographically secure random source for version 4.
  • Lowercase is the canonical text form; normalise case before comparing strings.
  • Do not use a UUID as a secret. It identifies; it does not authorise.
  • Validate incoming IDs with a strict pattern before database lookups.

When a UUID is the wrong tool

A 36-character code is hard to read over the phone. For a booking reference a customer will repeat to the front desk, use a short human-friendly code alongside the UUID, such as six characters from an alphabet without confusing letters like O and 0. Keep the UUID as the internal key.

Checking a generator

  1. Generate a batch and confirm the version digit matches the version you chose.
  2. For version 7, confirm that IDs created later sort after earlier ones.
  3. Confirm no IDs repeat in a large test batch.
  4. Read the tool's documentation for its random source.