Overview
The "Variables Get" node allows users to retrieve global variables within an n8n workflow. It serves as an alternative to the paid Variables feature by enabling access to stored variables without additional costs. This node is useful when you want to dynamically fetch values that are shared across different parts of a workflow or between workflows.
Common scenarios include:
- Fetching configuration settings or API keys stored as global variables.
- Retrieving user-defined flags or counters to control workflow logic.
- Accessing environment-specific data without hardcoding it in the workflow.
For example, you might use this node to get a variable named apiToken and then use that token in subsequent HTTP requests.
Properties
| Name | Meaning |
|---|---|
| Operation | The action to perform: - Get Variable: Retrieve a single variable's value. - Get All Variables: Retrieve all variables as an object. - List Variable Names: Get a list of all variable names. |
| Variable Name | (Required for "Get Variable" operation) The name of the variable to retrieve. |
| Default Value | (Optional for "Get Variable") The value to return if the specified variable does not exist. |
| Fail on Missing | (Optional for "Get Variable") Whether to fail the node execution if the variable does not exist (true or false). |
Output
The node outputs JSON data structured according to the selected operation:
Get Variable: Outputs an object with two fields:
{ "variableName": "name_of_variable", "value": "value_of_variable_or_default" }If the variable does not exist and
Fail on Missingis false, the output contains the default value orundefined.Get All Variables: Outputs a JSON object containing all variables as key-value pairs:
{ "var1": "value1", "var2": "value2", ... }List Variable Names: Outputs an object with:
{ "variables": ["var1", "var2", ...], "count": number_of_variables }
The node does not output binary data.
Dependencies
- Requires access to a global variable storage system provided by the workflow environment.
- No external API keys or services are needed.
- No special environment variables or credentials are required.
Troubleshooting
- Missing Variable Name: If the "Variable Name" property is empty when using the "Get Variable" operation, the node will throw an error stating that the variable name is required.
- Variable Not Found: If the requested variable does not exist and "Fail on Missing" is enabled, the node will throw an error indicating the variable does not exist. To avoid failure, either provide a default value or disable "Fail on Missing".
- Unknown Operation: If an unsupported operation is selected, the node will throw an error about the unknown operation.
- Continue On Fail: If enabled, errors for individual items will be captured in the output JSON under an
errorfield instead of stopping the entire workflow.