Skip to content

Add support for generating UUIDv7s #62529

Description

@jreidgreer

What is the problem this feature will solve?

UUIDv7s are time-based UUIDs which can be helpful for sorting & database distribution. The standard is published here: https://datatracker.ietf.org/doc/html/rfc9562#name-uuid-version-7

Postgres recently shipped native support for UUIDv7 generation, and Bun has a helper Bun.randomUUIDv7();

Having to reach for a library in order to generate non-v4 UUIDs is a bummer and adds bloat for a very common workflow.

What is the feature you are proposing to solve the problem?

I'm proposing UUIDv7 generation support be included in the Crypto module.

The actual API for this could either follow Bun's path of a separate method .createRandomUUIDv7(), or add in a property to the existing createRandomUUID options parameter such as version. These are not mutually exclusive, and you could imagine the parameter & method both existing for convenience.

Examples:

const {
  createRandomUUIDv7,
  createRandomUUID
} = await import('node:crypto');

createRandomUUIDv7();
// => "019d45ea-151f-780b-82a6-d097b39db62a"

createRandomUUID({
  version: "v7"
});
// => "019d45ea-fc8e-7792-bfa1-ae58916be0e3"

What alternatives have you considered?

No response

Activity

  1. nabeel378 commented on Apr 1, 2026

    @nabeel378
    Contributor

    Hi, I’m interested in implementing UUIDv7 support in the crypto module.
    I plan to create a createRandomUUIDv7() method following the RFC.
    Please let me know if this aligns with maintainers’ expectations.

  2. jasnell commented on Apr 1, 2026

    @jasnell
    Member

    @nabeel378 ... no need to ask permission! Just go for it. A few recommendations: keep the implementation as simple as possible, include tests and documentation. Keeping it as a separate function createRandomUUIDv7 without touching the existing createRandomUUID is ideal. Happy to review it once implemented.

  3. nabeel378 commented on Apr 2, 2026

    @nabeel378
    Contributor

    @jasnell Done! PR here: #62553

  4. added
    cryptoIssues and PRs related to the crypto subsystem.
    on Apr 2, 2026
  5. moved this from Awaiting Triage to In Progress in Node.js feature requestson Apr 2, 2026
  6. Delapouite commented on Apr 3, 2026

    @Delapouite
    Contributor

    @panva and @jasnell : do you think this useful feature should also trickle to the WebCrypto WG and/or Winter TC in order to be standardized across all runtimes?

  7. panva commented on Apr 3, 2026

    @panva
    Member

    You can certainly propose it as a feature in the Web Cryptography tracker. The judge of its usefulness there will be implementer interest, seldomly has niche use case user interest translated to adoption tho.

    Its mere presence in node:crypto should have it trickle down to runtimes such as Deno, Bun and Cloudflare Workers through their node compatibility layers, such that they are.

  8. damianremington274-blip commented on Apr 3, 2026

    @damianremington274-blip
  9. htunnicliff commented on Aug 27, 2026

    @htunnicliff

    In case anyone is interested in weighing in, I've added a proposal for this in the WebCrypto WG:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cryptoIssues and PRs related to the crypto subsystem.feature requestIssues requesting new Node.js features.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions