Data List Comparison and Reconciliation Utility - n8n Workflow

Use this robust n8n workflow to compare two arrays of JSON objects based on a custom key, efficiently identifying common items and unique differences for data reconciliation tasks. Find more useful n8n templates.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Ideal Users for this n8n workflow

Data Engineers and Analysts: Who need quick, programmatic ways to reconcile data sets coming from different sources.
Automation Specialists: Seeking modular n8n templates for common utility tasks within larger data pipelines.
Developers: Requiring precise object comparisons based on unique identifiers (like IDs or transaction keys) inside their n8n data flows.
Users of n8n: Looking for examples of powerful custom logic implemented within a Code n8n node.

Overview

Data auditing and synchronization frequently require determining which records two separate lists share and which records are unique to each source. Writing this logic repeatedly can be time-consuming. This reusable n8n workflow solves this problem by providing a highly efficient, customizable utility to perform a set comparison on two input arrays (inputa and inputb), using a dynamic key field for identification. The result is three distinct arrays that streamline reconciliation tasks. Integrating this specialized comparison logic via a callable n8n workflow ensures consistency and reusability across all your n8n deployments. This n8n template is designed for maximum efficiency, utilizing Map objects within the custom Code n8n node.

How it Works

This powerful data reconciliation tool starts with the When Executed by Another Workflow n8n trigger node, expecting three inputs: inputa (the first list), inputb (the second list), and the unique comparison key.


  1. Input Validation: The subsequent Switch n8n node first validates the incoming data. It checks if the key, inputa, or inputb are empty. If any of these mandatory fields are missing, the workflow branches to one of the respective Set n8n nodes (e.g., validation_message 1) to provide a clear error message in the output.

  2. Core Comparison: If all validation checks pass (routed via the 'Extra' fallback output), the flow proceeds to the crucial Code n8n node.

  3. Custom Code Execution: The custom Code n8n node executes JavaScript using efficient Map structures to map items by the comparison key. It performs lookups to categorize every object into one of three resulting output arrays: common (items found in both lists), onlyInA (items unique to the first list), and onlyInB (items unique to the second list).

This structured approach ensures the n8n workflow processes data correctly and provides immediate feedback if mandatory inputs are missing.

Installation Guide

To deploy this useful n8n workflow template, follow these steps:


  1. Import the JSON: Copy the provided n8n workflow JSON code.

  2. In your n8n instance, navigate to 'Workflows' and click 'New'.

  3. Select 'Import from JSON' and paste the copied data.

  4. Execution Setup: Since this uses the When Executed by Another Workflow n8n trigger, it is meant to be called from a parent n8n workflow using the 'Execute Workflow' n8n node.

  5. Input Configuration: When calling this n8n template, ensure you map the required data fields (inputa, inputb as arrays of objects, and key as the string name of the common identifier field) into the inputs defined by the n8n trigger node.

Node Details

This n8n workflow utilizes core nodes for robust data processing and flow control:

When Executed by Another Workflow (n8n trigger): The starting point, defined to receive three inputs (inputa, inputb, key). This allows the n8n workflow to be modularly called by other processes.
Switch (n8n node): Acts as a primary validation gate. It checks for null or empty values in the three required input variables (key, inputa, inputb). If validation fails, execution is diverted to an error message setting node.
Set (n8n node - e.g., validation_message 1): Used on validation failure branches to set a descriptive error message in the output data.
Code (n8n node): Contains the core JavaScript logic. This custom n8n node uses Map operations to provide O(N) efficiency for comparing the lists based on the dynamic key. It generates three categorized lists (common, onlyInA, onlyInB) for the final n8n workflow output.

Related n8n Workflows

Free

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

I'm a software developer with over 11 years of experience building systems across various stacks. I'm now applying that expertise to create practical and scalable workflow automations with n8n — focusing on clean logic, real-world use cases, and reusability. Always open to learning, sharing, and collaborating.

Featured*