Base64 icon

Base64

Encode text to Base64 or decode Base64 to text

Actions2

Decode

AI-generated

Overview

This node provides Base64 encoding and decoding functionality. It can convert plain text into its Base64 representation or decode a Base64 string back into readable text. This is useful in scenarios where data needs to be safely transmitted or stored in text form, such as embedding binary data in JSON, handling file contents, or working with APIs that require Base64-encoded payloads.

Practical examples:

  • Encoding user input or file content to Base64 before sending it to an API.
  • Decoding Base64 strings received from webhooks or external services to retrieve the original text.

Properties

Name Meaning
Operation Choose between "Encode" (convert text to Base64) or "Decode" (convert Base64 to text).
Base64 The Base64 string to decode (shown only when Operation is "Decode").
Text The text to encode to Base64 (shown only when Operation is "Encode").

Output

The node outputs an array of items, each containing a json object with a single field:

  • result: A string representing either the Base64 encoded text (if encoding) or the decoded UTF-8 text (if decoding).

No binary data output is produced by this node.

Example output JSON structure:

{
  "result": "SGVsbG8gd29ybGQ="
}

or after decoding:

{
  "result": "Hello world"
}

Dependencies

  • No external services or API keys are required.
  • Uses Node.js Buffer class for Base64 encoding/decoding internally.
  • No special n8n environment variables or credentials needed.

Troubleshooting

  • Invalid Base64 string error: When decoding, if the provided Base64 string is malformed or invalid, the node throws an error indicating "Invalid Base64 string". To resolve, ensure the input Base64 string is correctly formatted without extra characters or missing padding.
  • Empty or missing input text will cause the node to fail or produce empty results; always provide valid input according to the selected operation.
  • Encoding non-text binary data as input text may lead to unexpected results since the input is treated as UTF-8 string.

Links and References

Discussion