Encode
AI-generatedOverview
This node provides functionality to encode text into Base64 format or decode Base64 strings back into plain text. It is useful in scenarios where data needs to be safely transmitted or stored in a text-based format, such as embedding binary data in JSON, URLs, or XML. For example, you might use this node to encode sensitive information before sending it over a network or to decode Base64-encoded data received from an external service.
Properties
| Name | Meaning |
|---|---|
| Operation | Choose between "Encode" (convert text to Base64) or "Decode" (convert Base64 string back to text). |
| Text | The input string to process. When encoding, this is the plain text to convert to Base64. When decoding, this is the Base64 string to convert back to text. |
Output
The node outputs an array of items, each containing a json object with a single field:
result: A string representing the encoded Base64 text if encoding was selected, or the decoded plain text if decoding was selected.
No binary data output is produced by this node.
Example output JSON structure:
{
"result": "SGVsbG8gd29ybGQ="
}
Dependencies
- No external services or API keys are required.
- The node uses Node.js Buffer class for encoding and decoding operations.
- No special n8n environment variables or configurations are needed.
Troubleshooting
- Invalid Base64 string error: When decoding, if the input string is not a valid Base64 encoded string, the node will throw an error indicating "Invalid Base64 string". To resolve this, ensure that the input string is correctly Base64 encoded without any corruption or invalid characters.
- Ensure that the "Text" property is provided and not empty, as it is required for both encoding and decoding operations.