Skip to main content
On this page

@std/uuid

Overview Jump to heading

Generators and validators for RFC 9562 UUIDs for versions v1, v3, v4, v5, v6 and v7.

Use the built-in crypto.randomUUID() function instead of this package, if you only need to generate v4 UUIDs.

Based on npm:uuid.

import { v5, NAMESPACE_DNS, NIL_UUID } from "@std/uuid";
import { assert, assertFalse } from "@std/assert";

const data = new TextEncoder().encode("deno.land");
const uuid = await v5.generate(NAMESPACE_DNS, data);

assert(v5.validate(uuid));
assertFalse(v5.validate(NIL_UUID));

Add to your project Jump to heading

deno add jsr:@std/uuid

See all symbols in @std/uuid on

What is a UUID? Jump to heading

A UUID (Universally Unique Identifier) is a 128-bit identifier used to uniquely identify information in computer systems. UUIDs are designed to be globally unique, meaning that the probability of two UUIDs being the same is extremely low, even if they are generated independently in different systems. This makes UUIDs useful for a variety of applications, such as database keys, session identifiers, and distributed computing, where unique identification is crucial.

Why use @std/uuid? Jump to heading

To generate or validate UUIDs across versions (v1, v3, v4, v5, v6, v7). Prefer built-in crypto.randomUUID() if you only need v4.

Examples Jump to heading

import { v4 } from "@std/uuid";

const id = v4.generate();
console.log(v4.validate(id)); // true

Tips Jump to heading

  • Namespaced IDs: use v3/v5 for deterministic IDs based on a name + namespace.
  • Time-ordered IDs: consider v6/v7 for better index locality.

Did you find what you needed?

Privacy policy