What is UUID?

UUID (Universally Unique Identifier) is a 128-bit identifier that is guaranteed to be unique across all space and time. UUIDs are represented as 32 hexadecimal digits, displayed in five groups separated by hyphens (8-4-4-4-12 format).

Quick Facts

Full NameUniversally Unique Identifier
Created1980s (standardized in RFC 4122 in 2005)
SpecificationOfficial Specification

How It Works

UUID meaning is Universally Unique Identifier, and it is sometimes referred to as GUID in Microsoft ecosystems. UUIDs are generated using algorithms that combine various sources of uniqueness such as timestamps, random numbers, and hardware addresses. There are several versions: Version 1 uses timestamp and MAC address, Version 4 uses random numbers (most common), Version 5 uses namespace and name with SHA-1 hashing. The probability of generating duplicate UUIDs is so low that it's considered practically impossible. UUIDs are widely used in distributed systems where unique identifiers are needed without central coordination. UUID v7 (RFC 9562, 2024) introduces time-ordered UUIDs that combine the benefits of UUIDs with natural sorting by creation time. The first 48 bits encode a Unix timestamp in milliseconds, followed by random bits. This makes v7 ideal for database primary keys where chronological ordering improves index performance and query efficiency.

Key Characteristics

  • 128-bit length providing 2^128 possible values
  • Standardized format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  • Multiple versions for different use cases (v1, v4, v5, etc.)
  • Can be generated without central authority
  • Collision probability is negligible for practical purposes
  • Case-insensitive (uppercase and lowercase are equivalent)

Common Use Cases

  1. Database primary keys in distributed systems
  2. Session identifiers in web applications
  3. File and resource naming
  4. Transaction IDs in microservices
  5. Device identification

Example

loading...
Loading code...

Frequently Asked Questions

What is the difference between UUID and GUID?

UUID (Universally Unique Identifier) and GUID (Globally Unique Identifier) are essentially the same thing - both are 128-bit identifiers with the same format. GUID is the term used by Microsoft in Windows and .NET, while UUID is the term used in most other contexts and in the official RFC specification. They are fully compatible and interchangeable.

Which UUID version should I use?

UUID v4 (random) is the most commonly used and recommended for general purposes due to its simplicity and strong uniqueness. UUID v7 (time-ordered) is ideal for database primary keys because it maintains chronological ordering and improves index performance. UUID v1 (timestamp + MAC address) exposes machine information so it's less common now. UUID v5 is used for deterministic generation from namespace and name.

Can UUID collisions actually happen?

While theoretically possible, UUID v4 collisions are practically impossible. With 122 random bits, you would need to generate about 2.71 quintillion UUIDs to have a 50% chance of collision. To put this in perspective, generating 1 billion UUIDs per second would take about 85 years to reach that probability. For all practical purposes, UUIDs can be considered unique.

How do I generate a UUID in different programming languages?

In JavaScript: crypto.randomUUID() or use the 'uuid' npm package. In Python: import uuid; uuid.uuid4(). In Java: UUID.randomUUID(). In PHP: use Ramsey\Uuid\Uuid or uniqid() for simpler needs. In C#: Guid.NewGuid(). In Go: use the google/uuid package. Most modern languages have built-in or standard library support for UUID generation.

Should I use UUID or auto-increment ID for database primary keys?

Both have trade-offs. UUIDs are better for distributed systems (no coordination needed), data merging, and security (IDs aren't guessable). Auto-increment IDs are more space-efficient, human-readable, and have better index performance with B-tree indexes. UUID v7 offers a middle ground with time-ordering for better index performance. Consider using UUIDs for distributed systems and auto-increment for single-database applications.

Related Tools

Related Terms

GUID

GUID (Globally Unique Identifier) is Microsoft's implementation of the UUID standard, a 128-bit identifier used to uniquely identify information in computer systems. GUIDs and UUIDs are essentially the same thing with different names.

NanoID

NanoID is a tiny, secure, URL-friendly unique string ID generator for JavaScript. It generates compact identifiers that are shorter than UUIDs while maintaining similar collision resistance.

AI Code Review

AI Code Review is an automated code review technique that integrates artificial intelligence (specifically Large Language Models like GPT-4 or Claude 3.5 Sonnet) into the Software Development Life Cycle (SDLC). When a developer submits code changes (such as a GitHub Pull Request or GitLab Merge Request), an AI Agent acts as a virtual senior engineer. It automatically reads the Diff, contextualizes the project, coding guidelines, and best practices, and quickly points out logical flaws, security vulnerabilities, performance bottlenecks, and stylistic issues. It posts comments directly on the specific lines of code and often generates fix snippets.

Jailbreak

Jailbreaking, in the context of Artificial Intelligence, refers to an advanced adversarial prompting technique. Attackers use carefully crafted, highly creative language inputs to bypass the built-in safety guardrails and human alignment of foundational Large Language Models (like GPT-4, Claude, Llama). Once successfully jailbroken, the model ignores the ethical and safety guidelines it was trained on, generating strictly prohibited content such as malware code, bomb-making recipes, or hate speech.

Related Articles