File Global Variable icon

File Global Variable

Manage global variables via a JSON file

Overview

This node manages global variables stored in a JSON file on the filesystem. It allows users to get, set, delete individual variables, list all variables, or delete all variables at once. This is useful for workflows that need persistent storage of key-value pairs outside of n8n’s internal context, enabling sharing of data across different workflow executions or nodes.

Common scenarios include:

  • Storing configuration values or tokens that multiple workflows can access.
  • Persisting state information between workflow runs.
  • Managing feature flags or toggles via a simple JSON file.

For example, you could use this node to save API tokens securely in a JSON file and retrieve them when needed, or to keep track of counters or flags that influence workflow logic.

Properties

Name Meaning
File Path The path to the JSON file where global variables are saved and read from. Default is ~/.n8n/global_variables.json.

Note: Although the operation property exists in the node, for this summary only the "List ALL" operation is relevant as per your request.

Output

The output JSON contains a single field:

  • variables: An object representing all key-value pairs currently stored in the JSON file. Each key corresponds to a variable name, and its value is the stored value (which can be string, number, boolean, object, or array depending on what was saved).

Example output JSON structure:

{
  "variables": {
    "apiToken": "123abc",
    "maxRetries": 5,
    "featureEnabled": true,
    "userSettings": {
      "theme": "dark"
    },
    "items": [1, 2, 3]
  }
}

No binary data output is produced by this node.

Dependencies

  • Requires access to the local filesystem to read/write the JSON file specified by the File Path property.
  • No external APIs or services are required.
  • The node ensures the directory for the file path exists, creating it if necessary.

Troubleshooting

  • File not found or inaccessible: If the specified file path does not exist, the node will create an empty JSON file. However, permission issues may cause errors.
  • Invalid JSON format: If the JSON file content is corrupted or invalid, the node throws an error indicating failure to parse the JSON file. To fix, ensure the file contains valid JSON.
  • Unknown action error: If an unsupported operation is specified, the node throws an error. For "List ALL", this should not occur.
  • Empty or missing file path: The file path is required; leaving it empty will cause an error.

Links and References

Discussion