Special UUID

Nil UUID (Empty UUID)

The special UUID where all 128 bits are set to zero. Used as a placeholder, default value, or to indicate the absence of a UUID.

00000000-0000-0000-0000-000000000000

Copy in different formats:

What is the Nil UUID?

The Nil UUID (also called null UUID, zero UUID, or empty UUID) is a special UUID defined in RFC 4122 Section 4.1.7 where all 128 bits are set to zero:

00000000-0000-0000-0000-000000000000

Unlike other UUID versions that are generated with timestamps, random numbers, or hashes, the Nil UUID is a fixed constant. It's not "generated"—it's simply a predefined value that serves specific purposes in software development.

Technical Details

  • Hexadecimal: 00000000000000000000000000000000
  • Binary: 128 zeros
  • Integer value: 0
  • Variant: Technically none (doesn't follow RFC 4122 variant bits)
  • Version: None (version bits are also zero)

When to Use the Nil UUID

The Nil UUID has several common use cases in software development:

Default/Placeholder Value

Use as a default value for UUID columns before a real UUID is assigned. Better than NULL in some cases because it's still a valid UUID format.

Indicate "No UUID"

Represent the absence of a UUID without using NULL. Useful in languages or systems where NULL handling is problematic.

Initial/Unset State

Indicate that a UUID field hasn't been set yet, distinguishing between "not yet assigned" and "explicitly set to a value."

Testing & Development

Use in test fixtures as a recognizable, predictable UUID value. Easy to spot in logs and debugging output.

When NOT to Use Nil UUID

  • As a unique identifier: It's not unique—everyone uses the same Nil UUID
  • As a primary key: Multiple records would have the same "unique" key
  • For foreign key relationships: Could create unintended references
  • Where NULL is appropriate: Sometimes NULL better represents "no value"

Nil UUID in Programming Languages

Most UUID libraries provide a constant or method for the Nil UUID:

import uuid

# Get the Nil UUID
nil_uuid = uuid.UUID(int=0)
# Or: nil_uuid = uuid.UUID('00000000-0000-0000-0000-000000000000')

print(nil_uuid)  # 00000000-0000-0000-0000-000000000000

# Check if a UUID is nil
if my_uuid == uuid.UUID(int=0):
    print("This is the Nil UUID")
JavaScript (uuid package) Full guide →
import { NIL as NIL_UUID, validate } from 'uuid';

console.log(NIL_UUID);  // '00000000-0000-0000-0000-000000000000'

// Check if a UUID is nil
const isNil = (uuid) => uuid === NIL_UUID;

// Validate - Nil UUID is technically valid
console.log(validate(NIL_UUID));  // true
import java.util.UUID;

// Create Nil UUID
UUID nilUuid = new UUID(0L, 0L);
System.out.println(nilUuid);  // 00000000-0000-0000-0000-000000000000

// Check if nil
boolean isNil = uuid.getMostSignificantBits() == 0 
             && uuid.getLeastSignificantBits() == 0;
C# / .NET Full guide →
// .NET has built-in support for Empty GUID
Guid nilGuid = Guid.Empty;
Console.WriteLine(nilGuid);  // 00000000-0000-0000-0000-000000000000

// Check if empty
if (myGuid == Guid.Empty)
{
    Console.WriteLine("This is the Empty/Nil GUID");
}
import "github.com/google/uuid"

// Nil UUID is the zero value of uuid.UUID
var nilUUID uuid.UUID  // Automatically zero-initialized
fmt.Println(nilUUID)   // 00000000-0000-0000-0000-000000000000

// Or use the Nil constant
nilUUID = uuid.Nil

// Check if nil
if id == uuid.Nil {
    fmt.Println("This is the Nil UUID")
}

Nil UUID in Databases

PostgreSQL
-- Cast string to UUID
SELECT '00000000-0000-0000-0000-000000000000'::uuid;

-- Use as default (though NULL is often better)
CREATE TABLE items (
    id UUID DEFAULT '00000000-0000-0000-0000-000000000000'::uuid,
    parent_id UUID  -- NULL when no parent
);

-- Find records with Nil UUID
SELECT * FROM items WHERE parent_id = '00000000-0000-0000-0000-000000000000';
MySQL
-- Store as CHAR(36)
INSERT INTO items (id) VALUES ('00000000-0000-0000-0000-000000000000');

-- Or as BINARY(16)
INSERT INTO items (id) 
VALUES (UNHEX('00000000000000000000000000000000'));

Nil UUID vs Max UUID

RFC 9562 (2024) introduces a companion to the Nil UUID called the Max UUID, where all 128 bits are set to one:

UUID Value Use Case
Nil UUID 00000000-0000-0000-0000-000000000000 Minimum value, "no UUID"
Max UUID ffffffff-ffff-ffff-ffff-ffffffffffff Maximum value, range boundaries

The Max UUID is useful for range queries, sorting boundaries, and similar scenarios where you need the maximum possible UUID value.

Generate Real UUIDs

Need actual unique identifiers? Try our UUID generators:

Frequently Asked Questions

Is the Nil UUID valid?

Yes, the Nil UUID is explicitly defined in RFC 4122 as a valid special case. It follows the UUID format (8-4-4-4-12 hexadecimal digits) and most UUID validation libraries accept it. However, some strict validators may reject it because the version and variant bits are all zeros.

Should I use Nil UUID or NULL in databases?

Generally, use NULL when you mean "no value" or "not applicable." The Nil UUID should be reserved for specific cases where you need a valid UUID format but want to indicate "empty" or "unset." Using NULL is more conventional and allows for standard NULL handling in queries.

Can I use the Nil UUID as a primary key?

Technically yes, but practically no. Since there's only one Nil UUID, you can only have one record with that key. It defeats the purpose of using UUIDs for unique identification. Always generate a real UUID (v4 or v7) for primary keys.

What version is the Nil UUID?

The Nil UUID has no version. The version bits (positions 12-15 of the third group) are all zeros, which doesn't correspond to any defined UUID version. It's a special case outside the normal version numbering.

Copied to clipboard!