Overview
This node performs Base64 encoding and decoding on a given string value. It is useful in scenarios where data needs to be safely transmitted or stored in text form, such as embedding binary data in JSON, encoding credentials, or decoding Base64-encoded content received from APIs or files.
Practical examples:
- Encoding an image or file content into Base64 for inclusion in JSON payloads.
- Decoding Base64 strings received from webhooks or API responses back into their original text or JSON format.
Properties
| Name | Meaning |
|---|---|
| Action | Choose between "Base64 Encode" (convert a string to Base64) or "Base64 Decode" (convert Base64 string back to original). |
| Value | The string value to encode or decode. |
| Output Property Name | The name of the property in the output JSON where the encoded or decoded result will be stored. |
| Options (JSON Parse) | When decoding, optionally parse the decoded string as JSON if this option is enabled. |
Output
The node outputs an array of items, each containing a json object with the encoded or decoded value stored under the specified output property name.
- If encoding, the output property contains the Base64-encoded string.
- If decoding, the output property contains the decoded string or parsed JSON object if JSON parsing is enabled.
- Binary data from input items is preserved and passed through unchanged.
Example output JSON structure when decoding without JSON parse:
{
"data": "decoded string here"
}
When decoding with JSON parse enabled:
{
"data": {
"key": "value",
"anotherKey": 123
}
}
Dependencies
- Uses Node.js Buffer class for Base64 encoding/decoding.
- Uses lodash's
setfunction to dynamically set nested properties in the output JSON. - No external API or service dependencies.
- Requires standard n8n environment with access to Buffer and lodash.
Troubleshooting
- Invalid Base64 string error: Occurs if the input string to decode is not valid Base64. Ensure the input is correctly Base64 encoded.
- JSON parse errors: If JSON parsing is enabled but the decoded string is not valid JSON, a parsing error will occur. Disable JSON parse option or verify the input data format.
- Empty or missing input value: The node requires a non-empty string to encode or decode; ensure the "Value" property is properly set.
- Output property path issues: If specifying a nested output property name (e.g.,
parent.child), ensure the path is valid and does not conflict with existing data structures.
