UUID Generation: Versions, Case and Hyphens

Open Tool UUID Generator

What the segments mean

A standard UUID is thirty-six hexadecimal characters in an eight-four-four-four-twelve layout. The first character of the third group encodes the version, the first of the fourth encodes the variant. Browsers produce version four, essentially 122 random bits plus six fixed, so collisions are astronomically unlikely but not impossible. Version one draws on time and hardware address, leaking timing and device detail. Version seven leads with a timestamp and sorts well.

Steps

  1. Set the count with plus and minus or by typing a number.
  2. Choose lower or upper case, keeping one convention in databases and logs.
  3. Keep or drop hyphens, where dropping yields thirty-two characters.
  4. Generate the list, or load a sample to see the canonical shape.
  5. Copy all or download the batch.

Effect of hyphens and case

Hyphens are readability only, carrying no information, so the unhyphenated form stays valid but departs from canonical writing. A column sized thirty-six rejects the compact form; a column sized thirty-two truncates the hyphenated one. Case matters for string comparison, so the same UUID stored in both cases becomes two records. Agree one canonical form and normalise before insert rather than relying on inspections.

As a primary key

Workable, with costs. Random UUIDs scatter inserts across the index, splitting B-tree pages and hurting cache locality, so write-heavy tables do worse than with auto-increment integers. Options include time-ordered versions like seven, or keeping UUID as a business identifier with an integer key. Storage is heavier than eight bytes, indices grow, and humans misread them when copying by hand.

Common problems

Assuming absolute uniqueness — version four is random and a unique constraint remains sensible at scale. Building IDs from Math.random, whose predictability breaks security-relevant use. Treating a UUID as an auth token, when session credentials need longer unguessable randomness. Mixed formats within one system defeating deduplication. And reading the version nibble as a sequence number.

Fit and misfit:It fits distributed identifiers without a central service, temporary front-end objects, upload filenames and trace IDs. It does not fit human-readable, sortable or guessable numbering such as order codes carrying dates and business prefixes. It is no security credential. When strict monotonic sorting is required, timestamp-plus-sequence or ULID-style schemes serve better, since version four has no ordering.

⏫︎