Reusable Subworkflow for Dynamic File Compression and Zipping - n8n Workflow

Learn how to use this modular n8n workflow template to dynamically zip multiple files (images, PDFs, documents) into a single compressed archive using the n8n Compression node.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Automation specialists needing reusable n8n templates for common tasks.

  • Developers working on file management pipelines within n8n.

  • Users who frequently need to batch process and compress documents (PDFs, spreadsheets, images).

  • Anyone looking to understand how to dynamically manage binary properties using the n8n Code node.

Overview

Handling variable numbers of files for compression can be complex in automation platforms. This n8n workflow provides a sophisticated solution by designing a reusable sub-workflow specifically for dynamic file zipping. Instead of duplicating the compression logic in every parent n8n workflow, you simply call this module, passing the files you need to zip. This robust n8n template ensures that regardless of whether you input one image or twenty documents, they are efficiently bundled into a single ZIP file, named with a timestamp. This approach significantly streamlines complex file operations and demonstrates the power of modular design within the n8n environment. This core logic makes your main n8n workflow cleaner and easier to maintain.

How it Works

This modular n8n workflow starts with the execution trigger, expecting input items (files) from a parent n8n workflow.


  1. Execution Trigger: The Execute Workflow Trigger n8n node starts the process, awaiting input files from the calling n8n automation.

  2. Binary Preparation (Code Magic): The subsequent n8n Code node is crucial. It iterates through all incoming input items. For each item, it extracts the binary data and dynamically assigns it a unique key (e.g., data0, data1). It then compiles a comma-separated list of these newly created binary keys, which is passed forward as standard JSON data. This dynamic preparation is what allows the subsequent n8n node to handle any number of files.

  3. Compression: The Compression n8n node receives the input. Using the dynamic list provided by the previous n8n node, it grabs all the specified binary properties and compresses them into a single ZIP file. The file is automatically named using a timestamp (e.g., dataYYYY-MM-DD-HHmm.zip).

  4. Output Clean-up: The final Prepare Output n8n node uses the n8n Set node functionality to ensure the resulting ZIP file name has no spaces, optimizing it for transfer or storage in subsequent steps of the parent n8n workflow.

Installation Guide

To utilize this n8n workflow template, follow these steps:


  1. Import: Copy the entire JSON code provided and import it into your n8n instance via the 'Workflows' section using the 'New' -> 'Import from JSON' option.

  2. Deployment: Ensure the imported n8n workflow is set to 'Active' to allow it to be called by other workflows. This n8n workflow does not require external credentials.

  3. Usage (Parent Workflow): In your main n8n automation, gather the files you wish to compress. Then, use the Execute Workflow n8n node (not the trigger node) and configure it to call this specific sub-workflow. Ensure you pass the files as input items to the Execute Workflow n8n node.

Node Details


  • Execute Workflow Trigger (n8n trigger): Acts as the entry point for the sub-workflow, allowing it to be called programmatically by a parent n8n workflow.

  • Code Magic (n8n node): Essential scripting component. It dynamically extracts all incoming binary file data, renames the binary properties with sequential IDs, and generates a dynamic list of these IDs. This list is necessary for the next n8n node to identify all files to be compressed.

  • Compression (n8n node): Performs the heavy lifting. Configured to compress the files specified by the dynamically generated binary property list (={{ $json.binary_keys }}). The resulting filename is dynamically generated using the current date and time.

  • Prepare Output (n8n node): A standard n8n Set node used to post-process the output. Its main function here is to clean the generated filename, removing spaces to prevent issues when the zipped file is processed by cloud storage or transfer services later in the parent n8n workflow.

Related n8n Workflows

Free

Nodes: 5 Nodes
Updated: December 26 2025
View all
Created by
Simon
Simon

I am an E-commerce entrepreneur specializing in spare parts, with a strong passion for automation and AI. I leverage n8n to build complex workflows, integrating tools like SeaTable, Supabase with various E-com platforms. I'm dedicated to continuously improving workflow processes, particularly in the e-commerce sector.

Featured*