Variables Manager icon

Variables Manager

Manage global variables (import/export/backup)

Overview

The Variables Manager node allows users to manage global variables within an n8n workflow environment. It supports operations such as exporting all variables as JSON, importing variables from JSON data, retrieving information about the current variable storage, and creating backups of variables. This node is useful for scenarios where you want to persist, migrate, or audit global variables used across workflows.

Practical examples include:

  • Exporting variables before making significant workflow changes to ensure a backup.
  • Importing a set of predefined variables into multiple workflows to maintain consistency.
  • Checking the number and names of stored variables for debugging or documentation.
  • Creating backups of variables periodically for recovery purposes.

Properties

Name Meaning
Operation The action to perform: "Export Variables", "Import Variables", "Get Info", or "Backup Variables".
JSON Data JSON data to import when using the "Import Variables" operation.
Merge with Existing Boolean flag indicating whether to merge imported variables with existing ones (true) or replace them entirely (false). Applies only to the "Import Variables" operation.

Output

The node outputs a JSON object containing details relevant to the selected operation:

  • Export Variables:

    {
      "operation": "export",
      "variablesJson": "<stringified JSON of all variables>",
      "variablesCount": <number>,
      "exportedAt": "<ISO timestamp>",
      "success": true
    }
    

    Contains all exported variables as a JSON string, count of variables, and export timestamp.

  • Import Variables:

    {
      "operation": "import",
      "merged": <boolean>,
      "variablesCount": <number>,
      "importedAt": "<ISO timestamp>",
      "success": true
    }
    

    Indicates if variables were merged or replaced, updated count, and import timestamp.

  • Get Info:

    {
      "operation": "info",
      "variablesCount": <number>,
      "variableNames": ["<name1>", "<name2>", ...],
      "storagePath": "<file path string>",
      "success": true
    }
    

    Provides count, list of variable names, and the file path where variables are stored.

  • Backup Variables:

    {
      "operation": "backup",
      "backup": <parsed JSON object of all variables>,
      "variablesCount": <number>,
      "backupCreatedAt": "<ISO timestamp>",
      "success": true
    }
    

    Contains a parsed JSON backup of variables, count, and backup creation timestamp.

If an error occurs during execution, the output JSON will contain an error field with the message and "success": false.

The node does not output binary data.

Dependencies

  • Requires access to a variables storage system provided by the n8n environment.
  • No external API keys or services are needed.
  • Uses internal shared module for variable storage management.

Troubleshooting

  • Common Issues:

    • Providing invalid JSON in the "JSON Data" property during import can cause errors.
    • Attempting an unknown operation value will throw an error.
    • File system permission issues might prevent reading or writing variable storage files.
  • Error Messages:

    • "Unknown operation: <value>": Occurs if the operation parameter is set to an unsupported value. Ensure the operation is one of the supported options.
    • JSON parsing or import errors: Check that the JSON data provided is valid and correctly formatted.
    • Storage access errors: Verify that the n8n instance has proper permissions to read/write variable storage files.

To resolve errors, verify input parameters, ensure valid JSON format, and check environment permissions.

Links and References

Discussion