Learn how to use an n8n node Function to consolidate multiple incoming items into a single JavaScript array. Essential n8n workflow technique for data transformation.
Download this n8n workflow template and start using it instantly.
Data transformation is a core requirement for robust automation. While many n8n nodes generate individual output items (splitting the data), subsequent services often require a single, unified array containing all records. This powerful n8n workflow addresses this challenge by providing a reusable n8n node configuration that merges multiple items into one comprehensive JSON array.
This specific n8n template uses the Function n8n node to map the input items, solving the common problem of item consolidation efficiently and reliably, making your overall n8n workflow cleaner and faster.
This foundational n8n workflow begins without an external n8n trigger, relying instead on internal testing nodes to demonstrate the data flow.
items).items.map(item => item.json) to extract the raw payload from each individual n8n item and compile it into one cohesive JavaScript array.data_object. This technique ensures subsequent n8n nodes receive consolidated data, ready for bulk processing.To start using this data consolidation n8n workflow:
This n8n workflow utilizes two key Function n8n nodes:
Node Name: Mock Data (Function)
Function: Simulates the input data for the n8n workflow by generating three distinct n8n items, each containing a simple object (id and name).
Key Configuration: Contains hardcoded JavaScript returning an array of three separate objects to mimic the structure often seen after a Split In Batches or Database n8n node.
Node Name: Create an array of objects (Function)
Function: This critical n8n node performs the data consolidation, merging the separate incoming items into a single array structure.
Key Configuration: The JavaScript code used is return [ { json: { dataobject: items.map(item => item.json), }, } ];. This code maps over the input items, extracts the payload (item.json), and wraps the resulting JavaScript array into a single output item under the dataobject key. This demonstrates essential data manipulation techniques for any complex n8n template.
Automatically create Onfleet tasks whenever a specific file is updated in Google Drive. Use this essential n8n workflow template for logistics automation and real-time dispatch.

Create a dedicated API microservice to generate and decode India's DIGIPIN geolocation codes instantly using an n8n workflow. This n8n template uses pure JavaScript Code nodes for offline processing.

Build an advanced n8n workflow to chat conversationally with your Snowflake data warehouse using GPT-4o. Automate SQL generation, execute queries, and generate interactive HTML dashboards using this n8n template.

Build a powerful eBay Item Feed API service using an n8n workflow. Enable AI agents to query daily, hourly, or priority eBay data feeds via specialized n8n templates and nodes.









































