Encoding guide

Short UUID: Shortening UUIDs Safely

Learn how to make UUIDs shorter with Base64url and Base58 encoding without losing information, and when a shorter ID is worth it.

A UUID is 128 bits, but the standard 36-character text form is verbose. You can represent the same 128 bits in far fewer characters by encoding the raw bytes with Base64url or Base58, which keeps every bit while making the identifier shorter and URL-friendly.

Key takeaways

  • Removing hyphens gives 32 chars; encoding the bytes gives ~22.
  • Base64url (22 chars) and Base58 (~22 chars) are lossless and reversible.
  • Shortening changes presentation only; store the canonical UUID when in doubt.

Three levels of shortening

The simplest shortening is cosmetic: remove the hyphens to go from 36 to 32 hexadecimal characters. To go shorter, encode the 16 raw bytes with a denser alphabet. Base64url encodes 128 bits in 22 characters and is URL-safe. Base58 (the alphabet used by many crypto and short-link systems) avoids ambiguous characters like 0/O and l/1 and lands around 22 characters too.

All of these are lossless: the original UUID can be reconstructed exactly, because you are re-encoding the same 128 bits rather than truncating them.

UUID     : 123e4567-e89b-12d3-a456-426614174000  (36 chars)
No hyphen: 123e4567e89b12d3a456426614174000        (32 chars)
Base64url: Ej5FZ-ibEtOkVkJmFBdAAA                   (22 chars)

What not to do

Do not shorten by truncating a UUID to its first few characters. Dropping bytes throws away entropy and dramatically increases collision risk. Shortening should always re-encode the full 128 bits, never discard them.

Also avoid inventing a custom scheme when a standard one works. Base64url and Base58 are widely understood and easy to reverse in every language.

When shortening is worth it

Shorter identifiers help in URLs, QR codes, filenames and anywhere the 36-character form is awkward. If you only need a compact display form, encode on the way out and store the canonical UUID internally so your database, logs and tooling stay consistent.

If you find yourself wanting a natively short identifier rather than an encoded UUID, compare UUID with Nano ID and ULID before committing.

FAQ

Short UUID: Shortening UUIDs Safely questions

Does shortening a UUID lose information?

Not if you re-encode the full 128 bits with Base64url or Base58. It only loses information if you truncate characters, which you should never do.

What is the shortest safe UUID form?

Encoding the 16 raw bytes with Base64url or Base58 gives about 22 characters while preserving every bit of the original UUID.

Should I store the short form or the full UUID?

Store the canonical UUID (ideally in a native UUID column) and generate the short form for display. That keeps your data portable and unambiguous.

Short UUID - How to Shorten UUIDs Without Losing Data