Generate UUIDs (v1, v4, v5, v7)

generates UUIDs (Universally Unique Identifier) in v1, v4, v5 (deterministic) or v7 (time-ordered), compliant with RFC 4122

Why use UUIDs?

UUIDs (Universally Unique Identifiers) are unique identifiers used to guarantee uniqueness across different systems and databases without requiring central coordination. They are commonly used in distributed systems and web applications to generate unique identifiers for resources.

Supported UUID versions

This tool supports the following UUID versions:

  • Version 1: based on timestamp and MAC address.
  • Version 4: generated randomly (the most used).
  • Version 5: based on a SHA-1 fingerprint of a namespace and a name (deterministic: the same namespace + name pair will always produce the same UUID).
  • Version 7: time-ordered, recommended for modern database primary keys (lexicographic sort = chronological sort).

UUID v5: namespace and name

To generate a UUID v5, you must pick a standard namespace and provide a name:

  • DNS: to use when the name is a domain name (for example cdrn.fr).
  • URL: to use when the name is a URL (for example https://cdrn.fr/).
  • OID: to use when the name is an ISO object identifier.
  • X500: to use when the name is an X.500 distinguished name.

Since generation is deterministic, UUID v5 is particularly suited to producing reproducible identifiers from stable data.

How to generate UUIDs

On the home page, you can generate UUIDs by selecting the desired version from a dropdown and clicking the generate button. For version 5, also provide the namespace and the name.

As soon as a UUID is generated, it will appear in a green result line indicating that it was generated successfully. If an error occurs, a red line will display the matching error message.

Code examples to use the generated UUIDs

You can use the generated UUIDs in your applications by integrating them directly in your code. Here is a PHP example:


<?php
use Ramsey\Uuid\Uuid;

// Generate a UUID v4 (random)
$uuidV4 = Uuid::uuid4();

// Generate a UUID v5 (deterministic from a namespace and a name)
$uuidV5 = Uuid::uuid5(Uuid::NAMESPACE_DNS, 'cdrn.fr');

// Generate a UUID v7 (time-ordered)
$uuidV7 = Uuid::uuid7();

echo "UUID v4: " . $uuidV4->toString() . PHP_EOL;
echo "UUID v5: " . $uuidV5->toString() . PHP_EOL;
echo "UUID v7: " . $uuidV7->toString() . PHP_EOL;
?>

    

Validating and analysing UUIDs

You can also validate and analyse existing UUIDs to determine their version and validity. Here is a PHP code example:


<?php
use Ramsey\Uuid\Uuid;

// Validate a UUID
$uuidString = '123e4567-e89b-12d3-a456-426614174000';
if (Uuid::isValid($uuidString)) {
    $uuid = Uuid::fromString($uuidString);
    echo "Valid UUID of version: " . $uuid->getFields()->getVersion();
} else {
    echo "Invalid UUID";
}
?>

    

Frequently asked questions

What is the difference between UUID v1, v4, v5 and v7?

v1 combines a timestamp and the machine's MAC address, which can reveal sensitive information. v4 is purely random (122 bits of randomness), the most-used version. v5 is deterministic: the same namespace + name pair always produces the same UUID thanks to a SHA-1 hash. v7 embeds a millisecond timestamp at the start of the identifier, which makes it chronologically sorted and ideal for primary keys.

What is the collision probability of a UUID v4?

A UUID v4 has 122 random bits, that is about 5.3 × 10^36 possible values. To reach 50% collision probability (birthday paradox), you would need to generate about 2.7 × 10^18 UUIDs. In practice, on a standard application, the collision probability is negligible. That is what allows generating identifiers client-side without coordination with a central server.

Why prefer UUID v7 for a database primary key?

A UUID v4 inserted into a B-tree index causes strong fragmentation: each insertion lands at a random position, which degrades performance and cache use. UUID v7 starts with a millisecond timestamp, so new rows always insert at the end of the index. Insertion performance then approaches that of a BIGSERIAL, while keeping the benefits of a universal identifier.

What are the DNS, URL, OID and X500 namespaces of UUID v5 for?

These namespaces are predefined UUIDs in RFC 4122 that act as a contextual prefix for deterministic generation. DNS is used with a domain name, URL with a full URL, OID with an ISO object identifier, X500 with an LDAP distinguished name. You can also define your own private namespace: a UUID v4 generated once for your application, reused as the deterministic root for all your v5 identifiers.

UUID or auto-increment for database identifiers?

Auto-increment remains very efficient for monolithic databases and willingly reveals the write sequence, which may be undesirable on a public API. UUIDs are better suited to distributed architectures, client-side generation, database merges, and public exposure of opaque identifiers. The ideal compromise in 2026: UUID v7 as the primary key, which combines universality, reasonable opacity and good index performance.

Do the generated UUIDs go through a third-party server?

Generation runs in cdrn.fr's environment, without any call to an external service. For purely random (v4) or temporal (v7) versions, no sensitive information is needed as input. For v5, the namespace and the name you provide are only used for the local SHA-1 computation. No generated identifier is logged, you can use the tool to produce UUIDs for confidential contexts.

Example request

curl -X POST https://cdrn.fr/api/v1/tools/uuid-generator/execute \
  -H "Content-Type: application/json" \
  -d '{"version":"uuid_version_1","quantity":3,"namespace":"namespace_dns","name":"..."}'

Input schema

Field Type Required Default
version choice (uuid_version_1, uuid_version_4, uuid_version_5, uuid_version_7)
quantity integer 3
namespace choice (namespace_dns, namespace_url, namespace_oid, namespace_x500)
name string

Endpoints

  • GET https://cdrn.fr/api/v1/tools - lists every available tool
  • GET https://cdrn.fr/api/v1/tools/uuid-generator - returns the schema for this tool
  • POST https://cdrn.fr/api/v1/tools/uuid-generator/execute - runs this tool with a JSON payload