This template provides a robust, purely no-code solution for a common integration challenge: converting multiple binary files contained within a single n8n item (e.g., after unzipping an archive) into a structured JSON array of Base64 encoded strings.
Many external APIs, especially those handling batch file uploads or complex data structures, require files to be submitted as a single JSON payload. This payload typically needs an array containing two elements for each file: the reconstructed file path/name and the Base64 encoded content. This template automatically handles the file isolation, encoding, path reconstruction, and final JSON aggregation, replacing the need for complex custom JavaScript Code nodes.
{{ $binary.keys()[0] }}
to ensure the correct binary file is targeted and converted to Base64.path
(including the directory, if present) for each file.files
array, ready for your final API call.For a detailed walkthrough, including the explanation behind the dynamic expressions and why this is superior to the custom code solution, check out the full blog post: The No-Code Evolution: Base64 Encoding Multiple Files in n8n (Part 2).