This workflow corresponds to n8n.io template #5033 — we link there as the canonical source.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"id": "6oFu27D3MfMM86Oz",
"name": "comparer",
"tags": [],
"nodes": [
{
"id": "e13aefae-e377-4ebd-acd9-fb70aaefecfe",
"name": "When Executed by Another Workflow",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"position": [
0,
20
],
"parameters": {
"workflowInputs": {
"values": [
{
"name": "input_a",
"type": "array"
},
{
"name": "input_b",
"type": "array"
},
{
"name": "key"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "85588542-5fcb-415f-b189-bbb38f889bb5",
"name": "Code",
"type": "n8n-nodes-base.code",
"position": [
440,
320
],
"parameters": {
"jsCode": "const listA =$input.first().json.input_a ; \nconst listB = $input.first().json.input_b;\nconst key = $input.first().json.key;\n\nconst aMap = new Map(listA.map(item => [item[key], item]));\nconst bMap = new Map(listB.map(item => [item[key], item]));\n\nconst common = [];\nconst onlyInA = [];\nconst onlyInB = [];\n\nfor (const [k, itemA] of aMap) {\n if (bMap.has(k)) {\n common.push(itemA); // \u2190 keep A's version only\n } else {\n onlyInA.push(itemA);\n }\n}\n\nfor (const [k, itemB] of bMap) {\n if (!aMap.has(k)) {\n onlyInB.push(itemB);\n }\n}\n\nreturn [\n {\n json: {\n common: common,\n onlyInA: onlyInA,\n onlyInB: onlyInB\n }\n }\n];\n"
},
"typeVersion": 2
},
{
"id": "f1bee89d-54b2-4cf7-87f6-45e2f940b763",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-140,
-160
],
"parameters": {
"content": "## Pass in two list of item that you like to compare, as well as the key"
},
"typeVersion": 1
},
{
"id": "f04f1c66-e219-46a1-99ff-9e3df7f8d2fa",
"name": "Switch",
"type": "n8n-nodes-base.switch",
"position": [
220,
-1
],
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "673a0546-03d9-44d2-95ea-aecafb41a7d9",
"operator": {
"type": "string",
"operation": "empty",
"singleValue": true
},
"leftValue": "={{ $json.key }}",
"rightValue": ""
}
]
}
},
{
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "e95886e4-4664-40de-b177-1a4d17aa88d8",
"operator": {
"type": "array",
"operation": "empty",
"singleValue": true
},
"leftValue": "={{ $json.input_a }}",
"rightValue": ""
}
]
}
},
{
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "694a102f-2421-48df-9a17-a9270da0b9aa",
"operator": {
"type": "array",
"operation": "empty",
"singleValue": true
},
"leftValue": "={{ $json.input_b }}",
"rightValue": ""
}
]
}
}
]
},
"options": {
"fallbackOutput": "extra"
}
},
"typeVersion": 3.2,
"alwaysOutputData": true
},
{
"id": "4554a775-e6d4-4ae0-85ff-9564866d1464",
"name": "validation_message 1",
"type": "n8n-nodes-base.set",
"position": [
440,
-280
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "39e1492c-820e-4157-963e-cfa5c7d5d0a6",
"name": "validation_message",
"type": "string",
"value": "You must specify a key"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "0fa56f6d-3a28-4382-9916-ddaeb31e0310",
"name": "validation_message 2",
"type": "n8n-nodes-base.set",
"position": [
440,
-80
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "ca870eac-56f8-4c5f-9938-1bc53bce7f26",
"name": "validation_message",
"type": "string",
"value": "You must specify input_a"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "2c4b3b98-7a20-418c-af4e-4c2967532e31",
"name": "validation_message 3",
"type": "n8n-nodes-base.set",
"position": [
440,
120
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "ca870eac-56f8-4c5f-9938-1bc53bce7f26",
"name": "validation_message",
"type": "string",
"value": "You must specify input_b"
}
]
}
},
"typeVersion": 3.4
}
],
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "29cfe6be-abca-424c-99aa-ad781eb68e98",
"connections": {
"Code": {
"main": [
[]
]
},
"Switch": {
"main": [
[
{
"node": "validation_message 1",
"type": "main",
"index": 0
}
],
[
{
"node": "validation_message 2",
"type": "main",
"index": 0
}
],
[
{
"node": "validation_message 3",
"type": "main",
"index": 0
}
],
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"When Executed by Another Workflow": {
"main": [
[
{
"node": "Switch",
"type": "main",
"index": 0
}
]
]
}
}
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This workflow compares two lists of objects (List A and List B) using a user-specified key (e.g. , , ) and returns: Items common to both lists (based on the key) Items only in List A Items only in List B Accepts a JSON input containing: : the first list of items : the second…
Source: https://n8n.io/workflows/5033/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
Agendamiento. Uses n8n-nodes-evolution-api, redis, dataTable, executeWorkflowTrigger. Event-driven trigger; 60 nodes.
Prevent concurrent workflow runs using Redis. Uses executeWorkflowTrigger, manualTrigger, stickyNote, executeWorkflow. Event-driven trigger; 43 nodes.
This workflow sets a small "lock" value in Redis so that only one copy of a long job can run at the same time. If another trigger fires while the job is still busy, the workflow sees the lock, stops e
Reputation Engine — Site Refresh. Uses httpRequest, executeWorkflowTrigger. Event-driven trigger; 35 nodes.
Using n8n a lot?