Globals

Read and update persistent globals across workflows

Overview

This node manages persistent global data storage across workflows in n8n. It allows users to store, retrieve, increment, list, and delete key-value pairs in a persistent manner. The data can be stored either in a JSON file on disk or within the static data of the current workflow or node.

Common scenarios where this node is beneficial include:

  • Keeping counters or stateful values that persist between workflow executions.
  • Sharing configuration or state information across multiple workflow runs.
  • Storing flags or tokens that need to be reused or updated dynamically.
  • Managing simple persistent caches or global variables without external databases.

For example, you could use it to count how many times a workflow has run by incrementing a counter stored globally, or to save an API token retrieved once and reuse it later.

Properties

Name Meaning
Storage Where to keep persistent data. Options: File (JSON file on disk), Node (node static data), Workflow (workflow static data). Workflow and Node options require active workflow execution (not manual run).
Key The key name for the global value to get, set, increment, or delete.
Store File Path Optional path to the JSON file used to persist globals when using File storage. Defaults to the user n8n folder's globals.json.

Note: The above properties are relevant for the "Get" operation under the "Default" resource.

Output

The output is an array of items with a single item per input or one if no input exists. Each item contains a json object with the following structure for the "Get" operation:

{
  "key": "<the requested key>",
  "value": <the value associated with the key or null if not found>
}
  • If the key does not exist in the selected storage, the value will be null.
  • No binary data is output by this node.

Dependencies

  • Requires access to the filesystem if using File storage to read/write the JSON file.
  • For Node or Workflow storage, requires an active workflow context (cannot be run manually).
  • No external APIs or services are required.
  • Uses environment variable N8N_USER_FOLDER optionally to determine default file storage location.

Troubleshooting

  • Key is required error: The node throws an error if the "Key" property is empty for operations that require it (get, set, increment, delete). Ensure the key is provided.
  • File permission issues: When using File storage, ensure the node process has read/write permissions to the specified file path.
  • Invalid JSON in file: If the JSON file is corrupted or invalid, the node will treat it as empty but may cause unexpected behavior.
  • Using Node or Workflow storage outside active workflow: These storage options require an active workflow context; running the node manually may lead to errors or no data persistence.
  • Value type mismatch: For other operations like set or increment (not covered here), providing incompatible types may cause errors.
  • Unsupported operation error: If an unsupported operation is specified, the node will throw an error.

Links and References

Discussion