What are UUIDs? What format do they have? And how do you verify them?

A UUID (Universally Unique Identifier) is a 128-bit code used to uniquely identify a piece of data or a resource in a system, without needing a central authority to assign it. It is written with 36 characters: 32 hexadecimal characters in five groups (8-4-4-4-12) separated by hyphens.

UUIDs (Universally Unique Identifiers) are codes designed to be unique across computer systems, like a universal “serial number”.

It is extremely unlikely for two UUIDs to be the same, even if they are generated on different systems at the same time.

You may have seen them somewhere before; they follow a format similar to this:

550e8400-e29b-41d4-a716-446655440000

(32 hexadecimal characters grouped as 8-4-4-4-12 and separated by hyphens)

UUID versions

The first character of the third group indicates the version. In the example above, 550e8400-e29b-41d4-a716-446655440000, it is a version 4 UUID.

VersionHow it is generatedWhen it is used
v1Date and time + device identifier (MAC address)Older systems; it may expose device information
v3MD5 hash of a name + a namespaceWhen the same name must always produce the same UUID
v4RandomThe most widely used in APIs and applications
v5SHA-1 hash of a name + a namespaceSame as v3, but with a more secure hash
v6Like v1, but with the date reorderedWhen you need to sort by creation date
v7Unix timestamp + random partModern databases: they are unique and sortable
v8Custom formatSpecial cases defined by each system

In this video, I talk about a requirement that included this format and how to test it.

Frequently asked questions

What is a UUID?

A universally unique identifier: a code designed to be unique across computer systems, like a universal serial number.

What format does a UUID have?

32 hexadecimal characters in groups of 8-4-4-4-12 separated by hyphens, for example 550e8400-e29b-41d4-a716-446655440000.

How do I know which version a UUID is?

Look at the first character of the third group: that number is the version. For example, in 550e8400-e29b-41d4-a716-446655440000 it is a 4.

How do I validate a UUID in my tests?

Check that it has 36 characters, hyphens in the right positions, only hexadecimal characters (0-9 and a-f), the expected version, and that it is not repeated. A regular expression that works is: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$

Can two UUIDs be the same?

In theory yes, but the probability is so low that in practice they are considered unique. It is still worth testing how the system behaves if a duplicate UUID arrives.

Keep reading: Postman free plan update and What do software version numbers mean?. If you want to go deeper, I recommend the course API Testing with Postman.