Password Generator

UUID v1 Guide

How time-based UUID Version 1 works and when to use it

UUID v1 is a time-based UUID format defined in RFC 4122. It combines a timestamp, a clock sequence, and a node identifier to produce unique, mostly ordered identifiers.

What is UUID v1?

UUID Version 1 uses the current time and a node identifier—often a MAC address or a random node ID—to create a UUID. It is one of the oldest UUID versions, and it is useful when stable ordering or distributed generation is important.

550e8400-e29b-11d4-a716-446655440000
└───────┘ └──┘ └───┘ └───────────────┘
 time     ver  clock   node
             1     seq

How UUID v1 is generated

  • Convert the current timestamp into a 60-bit value based on the 1582 epoch.
  • Use a clock sequence to prevent duplicates when the clock moves backwards.
  • Include a node identifier, usually the machine's MAC address or a random node value.
  • Set the version bits to 0001 and the variant bits to 10.
  • Format the final 128-bit value as a standard UUID string.

When to use UUID v1

UUID v1 is a good choice for systems that need mostly ordered unique IDs and distributed generation without a central authority. It is commonly used for database keys, event timestamps, and legacy interoperability.

However, UUID v1 embeds time and node information, so it is not ideal for public identifiers where privacy matters. For public-facing IDs, consider UUID v4, v6, or v7 instead.

Code examples for UUID v1

uuid npm package

Generate UUID v1 values in Node.js and browser JavaScript.

# Install
npm install uuid
import { v1 as uuidv1 } from 'uuid';

const id = uuidv1();
console.log(id);

Python standard library

Use the built-in uuid module to generate UUID v1 values.

import uuid

uid = uuid.uuid1()
print(uid)

google/uuid

Generate UUID v1 values in Go using the google/uuid library.

# Install
go get github.com/google/uuid
package main

import (
    "fmt"
    "github.com/google/uuid"
)

func main() {
    id, err := uuid.NewUUID()
    if err != nil {
        panic(err)
    }
    fmt.Println(id)
}

java-uuid-generator

Use the JUG library for UUID v1 generation in Java.

<!-- Maven dependency -->
<dependency>
  <groupId>com.fasterxml.uuid</groupId>
  <artifactId>java-uuid-generator</artifactId>
  <version>5.1.0</version>
</dependency>
import com.fasterxml.uuid.Generators;
import java.util.UUID;

UUID id = Generators.timeBasedGenerator().generate();
System.out.println(id);

GuidCom library

Generate UUID v1 values in .NET with a third-party package.

# Install
dotnet add package GuidCOM
using GuidCOM;

var id = GuidGenerator.CreateTimeBased();
Console.WriteLine(id);

ramsey/uuid

Generate UUID v1 values in PHP with Ramsey UUID.

# Install
composer require ramsey/uuid
use Ramsey\Uuid\Uuid;

$id = Uuid::uuid1();
echo $id->toString();

uuidtools gem

Create UUID v1 values in Ruby using timestamp-based generation.

# Install
gem install uuidtools
require 'uuidtools'

puts UUIDTools::UUID.timestamp_create

uuid crate

Generate UUID v1 values in Rust with the uuid crate.

# Cargo.toml
[dependencies]
uuid = { version = "1", features = ["v1"] }
use std::time::{SystemTime, UNIX_EPOCH};
use uuid::{Timestamp, Uuid, v1::Context};

let context = Context::new(42);
let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
let ts = Timestamp::from_unix(&context, now.as_secs(), now.subsec_nanos());
let node_id = [0x01, 0x23, 0x45, 0x67, 0x89, 0xab];
let id = Uuid::new_v1(ts, &node_id).unwrap();
println!("{}", id);

Elixir UUID package

Generate UUID v1 values in Elixir using a UUID library from Hex.

# mix.exs dependencies
{:elixir_uuid, "~> 1.2"}
UUID = Elixir.UUID

id = UUID.uuid1()
IO.puts(id)

Erlang uuid library

Generate UUID v1 values in Erlang with a UUID dependency.

% rebar.config
{deps, [{uuid, "*"}]}
UUID = uuid:uuid1().
io:format("~s~n", [UUID]).

SQL storage

UUID v1 values are usually generated in application code before inserting them into the database.

CREATE TABLE items (
  id UUID PRIMARY KEY,
  name TEXT
);

-- Insert a UUID v1 generated by your application
INSERT INTO items (id, name) VALUES ('550e8400-e29b-11d4-a716-446655440000', 'example item');

Frequently asked questions

Is UUID v1 deterministic?

No. UUID v1 is time-based and depends on the timestamp, clock sequence, and node identifier, so it does not produce the same value for repeated calls.

Is UUID v1 still a good choice?

UUID v1 is still useful when you need mostly ordered IDs and distributed generation without a central coordination service. For public identifiers or privacy-sensitive use cases, newer UUID versions may be better.

Does UUID v1 expose private data?

Yes. UUID v1 contains timestamp and node data that may reveal generation time and machine identity. Avoid using UUID v1 for public or sensitive identifiers unless you understand the privacy implications.

Ready to generate? Open the UUID v1 generator →