What Is a UUID and When Should You Use One?

By the ToolPocket team · Updated 2026-12-05 · Editorial standards

A UUID looks like 3f2a8c1e-9b4d-4f6a-8e2b-1c7d5a9e0f34. That string is a 128-bit identifier, and the shape carries more information than most people realise.

A Universally Unique Identifier is a 128-bit value written as 32 hexadecimal digits in five groups. The standard is RFC 4122, and the version and variant fields are embedded in the string itself.

Versions

Why random is usually good

Version 4 UUIDs do not encode when or where they were created, which avoids leaking machine details and makes them safe to generate independently on many servers. The collision probability is astronomically small: you would need to generate billions per second for decades to make it likely.

The database trade-off

Random UUIDs scatter index inserts across the whole key space, which is much less efficient than sequential integers on a B-tree index. For high-volume tables, many teams now prefer UUIDv7, which keeps the uniqueness of a UUID while ordering by creation time.

When to use one

Storing UUIDs

A UUID is 16 bytes of data written as 36 characters of text. Storing it as char(36) wastes space and slows index comparisons; most databases offer a native UUID type or accept a 16-byte binary value. The saving is small per row and large per million rows.

Whatever the storage form, keep the textual form for APIs and logs. Mixing representations in one system is a reliable source of "not found" bugs that only appear at the boundary between services.

When not to

Do not use a UUID as a secret. It is an identifier, not an authentication token, and the randomness does not make it a substitute for a password or an API key.

Generate test data with the UUID generator, or check what a UUID contains with the hash generator when you are working with derived identifiers.

← All guides