Globals

Read and update persistent globals across workflows

Overview

This node manages persistent global data that can be shared across workflows or stored persistently on disk. It supports operations to list, get, set, increment, and delete key-value pairs in a global storage. The storage can be either a JSON file on disk or static data attached to the current workflow or node.

Common scenarios include:

  • Sharing configuration values or counters between different workflow executions.
  • Persisting state or counters that survive workflow restarts.
  • Managing global flags or settings accessible from multiple workflows.

For example, you could use this node to keep track of how many times a workflow has run by incrementing a counter stored globally, or store API tokens or other configuration parameters centrally.

Properties

Name Meaning
Storage Where to keep persistent data. Options:
- File: Store in a JSON file on disk.
- Node: Store in node static data (not recommended for persistence).
- Workflow: Store in workflow static data (requires active workflow, not manual run).
Store File Path Optional path to the JSON file used to persist globals when "File" storage is selected. Defaults to the user n8n folder's globals.json file.

Output

The node outputs an array of items with a single item per input or operation execution. Each output item contains a json object with fields depending on the operation:

  • List: Outputs all stored key-value pairs as properties of the JSON object.
  • Get: Outputs { key: string, value: any } where value is the stored value or null if missing.
  • Set: Outputs { key: string, value: any } showing the key and the newly set value.
  • Increment: Outputs { key: string, value: number } showing the key and the incremented numeric value.
  • Delete: Outputs { key: string, deleted: boolean } indicating whether the key was found and deleted.

No binary data is produced by this node.

Dependencies

  • Requires access to the filesystem if using "File" storage to read/write the JSON file.
  • Uses environment variable N8N_USER_FOLDER or defaults to the user's home .n8n directory for storing the default globals file.
  • No external API keys or services are required.

Troubleshooting

  • Missing Key Error: Operations like Get, Set, Increment, and Delete require a non-empty key. If omitted, the node throws an error.
  • Invalid Value Type: When setting a value, the node attempts to parse or convert the input based on the selected type (string, number, boolean, json). Invalid conversions throw errors.
  • Increment Errors:
    • If the existing value is not a number, an error is thrown.
    • If the key does not exist and "Initialize if Missing" is false, an error is thrown.
  • File Access Issues: When using file storage, ensure the specified file path is writable and readable by n8n. Permission issues or invalid paths may cause failures.
  • Workflow/Node Storage Limitations: Using workflow or node static data requires an active workflow context and will not persist beyond workflow reloads or manual runs.

To resolve errors, verify input parameters, ensure correct types, and check file system permissions if applicable.

Links and References

Discussion