Base64 Encoding for Multiple Binary Files via Custom Code - n8n Workflow

Learn how to use a custom JavaScript n8n node to process and convert multiple binary files from a ZIP archive into Base64 strings, crucial for various API uploads requiring this specific format. This n8n workflow template solves complex batch file handling.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Developers who need to upload multiple files to an API that strictly requires Base64 encoding.
Users of n8n who need advanced binary file manipulation beyond standard n8n nodes.
Automation specialists looking for robust n8n templates for file conversion tasks.
Anyone interested in leveraging the power of the n8n Code node for data processing.

Overview

This specialized n8n workflow template addresses a common integration challenge: processing zipped archives containing multiple binary files and converting them into Base64 strings for API consumption. While standard n8n nodes handle single-file Base64 encoding well, batch processing requires custom logic. This n8n workflow provides a robust solution by combining file download, decompression, and a carefully crafted n8n node running JavaScript to iterate over the extracted binaries and perform the necessary encoding. If you frequently handle compressed data and need to transform the contents efficiently, this n8n template is essential for your toolkit.

How it Works

The entire process is initiated by a simple manual n8n trigger, making it easy to test and deploy.


  1. Start: The 'When clicking ‘Execute workflow’' n8n trigger begins the automation run.

  2. Download: An HTTP Request n8n node downloads a sample ZIP file containing the files to be processed.

  3. Decompress: The subsequent Compression (Unzip) n8n node automatically processes the downloaded binary file, expanding the contents and outputting a separate item for each file found inside the ZIP, each with its own binary property.

  4. Encode (Custom Code): The core functionality resides in the 'Encode to base64' Code n8n node. This node uses custom JavaScript to iterate through the multiple binary items created by the Unzip n8n node. For each item, it uses the built-in this.helpers.getBinaryDataBuffer function to securely retrieve the file data as a buffer. This buffer is then converted into a Base64 string, and the output is structured neatly for subsequent n8n nodes, providing the file path and the encoded data.

Installation Guide

To start using this powerful n8n workflow template, follow these steps:


  1. Import: Copy the provided JSON data and navigate to your n8n instance.

  2. Click 'New' and then 'Import from JSON' and paste the code.

  3. No Credentials: This specific n8n workflow does not require external credentials as it uses public URLs and internal n8n nodes (HTTP Request, Code, Manual Trigger).

  4. Execution: Click the 'Execute Workflow' n8n trigger button to test the process immediately.

  5. Customization: Modify the 'Download n8n demo website zip' n8n node to point to your specific ZIP file source URL to adapt the n8n workflow to your needs. If your target API requires a different output structure, adjust the JavaScript within the Code n8n node accordingly.

Node Details

This n8n workflow relies on three main n8n nodes to achieve the file processing and conversion:

When clicking ‘Execute workflow’ (Manual Trigger n8n Trigger)
Function: Acts as the starting point for this on-demand n8n workflow.
Key Configuration: No configuration needed; it serves as a simple manual n8n trigger.

Download n8n demo website zip (HTTP Request n8n Node)
Function: Downloads the source ZIP file from a remote GitHub repository. This provides the binary data needed for processing.
Key Configuration: URL set to https://github.com/n8n-io/n8n-demo-website/archive/refs/heads/main.zip. Response format is critical, set to file to handle the data as binary.

Unzip (Compression n8n Node)
Function: Decompresses the downloaded ZIP file. This is crucial because it converts one input item (the ZIP) into multiple output items (the files within the ZIP), preparing them for the batch processing by the next n8n node.
Key Configuration: Uses default settings for decompression.

Encode to base64 (Code n8n Node)
Function: Iterates over all binary files generated by the Unzip n8n node. It uses custom JavaScript and n8n helpers (this.helpers.getBinaryDataBuffer) to retrieve the raw buffer of each file and then converts that buffer into a Base64 string, compiling the results into a structured JSON array.
Key Configuration: Contains the custom logic for Base64 encoding, ensuring efficient processing of multiple binary files in a single step within the n8n workflow.

Related n8n Workflows

Free

Nodes: 5 Nodes
Updated: December 26 2025
View all

Featured*