How to Generate UUIDs in n8n

Generate UUIDs in n8n Code nodes with JavaScript runtime features for v4. UUID v7 depends on whether your deployment allows the package or custom code path you need.

Compatibility note: not every n8n deployment allows the same external modules or custom packages. Treat UUID v7 as workflow-environment dependent.

How to generate UUID v4 in an n8n Code node

return [
  {
    json: {
      id: crypto.randomUUID(),
    },
  },
];

How to generate UUID v7 in n8n

UUID v7 is possible only if your n8n environment allows the code or package path you need. In many setups, this is not available by default.

// Example only when your deployment allows the uuid package
import { v7 as uuidv7 } from 'uuid';

return [
  {
    json: {
      id: uuidv7(),
    },
  },
];

Native support notes

  • n8n is a workflow platform, not a UUID runtime by itself.
  • UUID v4 is the safest documented path in Code nodes when runtime crypto is available.
  • UUID v7 support is deployment-specific and may require self-hosting or external module enablement.

Practical notes

  • Prefer UUID v4 when workflows must stay portable across hosted and self-hosted n8n environments.
  • Use UUID v7 only when you fully control the workflow runtime and package policy.
  • Validate output in the UUID validator when testing new workflow code.

Frequently Asked Questions

Yes. A Code node can usually generate UUID v4 locally if the JavaScript runtime exposes crypto support.

No. UUID v7 support depends on how the n8n deployment is configured and whether supporting modules are available.

Learn more

These articles expand on related concepts, formats and practical considerations.

By using this site, you agree to our Privacy Policy and Terms of Service. You are not permitted to use the GUIDs (also known as UUIDs) generated by this site or use any other content, services and information available if you do not agree to these terms.
Disclaimer: All information is provided for general educational and technical reference only. While we aim to keep the content accurate, current and aligned with published standards, no guarantees are made regarding completeness, correctness or suitability for any specific use case.
GUID specifications, best practices, security guidance, database behavior and ecosystem conventions (including cloud platforms and identifier formats) may change over time or differ by implementation. Examples, recommendations and comparisons are illustrative and may not apply universally.
This content should not be considered legal, security, compliance or architectural advice. Before making critical design, security or production decisions, always consult the latest official standards and vendor-specific documentation.
Always evaluate behavior in your own environment.
Standards Compliance: The GUIDs generated by this site conform to RFC 4122 and RFC 9562 specifications whenever possible, using cryptographically secure random number generation.