About UUIDs

Learn about Universally Unique Identifiers and their applications

What is a UUID?

A UUID (Universally Unique Identifier) is a 128-bit number used to identify information in computer systems. The term globally unique identifier (GUID) is also used, typically in Microsoft technologies.

UUIDs are typically displayed as 32 hexadecimal digits, displayed in five groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters (32 alphanumeric characters and four hyphens).

UUID Versions

Version 1 (Time-based)

Generated using the current timestamp, clock sequence, and MAC address. Guarantees uniqueness across time and space but may reveal information about when and where it was generated.

Use case: When you need to ensure temporal ordering

Version 4 (Random)

Generated using random numbers. This is the most commonly used version as it provides good uniqueness without revealing any information about the system that generated it.

Use case: General purpose unique identifiers

Version 7 (Time-ordered)

Uses a timestamp in milliseconds since Unix epoch followed by random data. Provides better database performance due to its time-ordered nature while maintaining randomness.

Use case: Database primary keys, time-series data

Nil UUID

A special UUID with all bits set to zero (00000000-0000-0000-0000-000000000000). Used to represent the absence of a UUID value.

Use case: Default/null values in databases

GUID

Essentially a Version 4 UUID but typically displayed in uppercase format. Commonly used in Microsoft technologies and COM interfaces.

Use case: Microsoft ecosystems, Windows applications

Common Use Cases

Database Primary Keys

UUIDs make excellent primary keys as they're unique across systems and don't reveal information about data volume.

API Resources

Used to identify resources in REST APIs without exposing internal system structure.

Session Identifiers

Generate unique session IDs that are hard to guess or predict.

File Names

Ensure unique file names in storage systems to prevent collisions.

Technical Specifications

Format

Standard format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (36 characters including hyphens)

Standards

Defined by RFC 4122 and ISO/IEC 9834-8:2005

Collision Probability

For Version 4 UUIDs, the probability of collision is approximately 1 in 5.3 x 10³⁶

Security Considerations

  • • Version 1 UUIDs can reveal MAC addresses and generation time
  • • Use Version 4 for security-sensitive applications
  • • Don't rely on UUIDs for cryptographic security
  • • Consider using Version 7 for database performance benefits