@ende/uuid

ende add jsr:@ende/uuid

Version 2026.10.15 on JSR.

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 "@ende/uuid";
import { assert, assertFalse } from "@ende/assert";

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

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

Modules

Exports

  • isNil — Determines whether the UUID is the nil UUID.
  • NAMESPACE_DNS — Name string is a fully-qualified domain name.
  • NAMESPACE_OID — Name string is an ISO OID.
  • NAMESPACE_URL — Name string is a URL.
  • NAMESPACE_X500 — Name string is an X.500 DN (in DER or a text output format).
  • NIL_UUID — The nil UUID is special form of UUID that is specified to have all 128 bits set to zero.
  • v1 — Generator and validator for UUIDv1.
  • v3 — Generator and validator for UUIDv3.
  • v4 — Validator for UUIDv4.
  • v5 — Generator and validator for UUIDv5.
  • v7 — Generator and validator for UUIDv7
  • validate — Determines whether a string is a valid UUID.
  • version — Detect RFC version of a UUID.