Jeicex's picture
Subindo documentação do n8n limpa
0a84888
metadata
contentType: howto
description: Merge data streams in you n8n workflows.

Merging data

Merging brings multiple data streams together. You can achieve this using different nodes depending on your workflow requirements.

  • Merge data from different data streams or nodes: Use the Merge node to combine data from various sources into one.
  • Merge data from multiple node executions: Use the Code node for complex scenarios where you need to merge data from multiple executions of a node or multiple nodes.
  • Compare and merge data: Use the Compare Datasets node to compare, merge, and output data streams based on the comparison.

Explore each method in more detail in the sections below.

Merge data from different data streams

If your workflow splits, you combine the separate streams back into one stream.

Here's an example workflow showing different types of merging: appending data sets, keeping only new items, and keeping only existing items. The Merge node documentation contains details on each of the merge operations.

[[ workflowDemo("https://api.n8n.io/workflows/templates/1747") ]]

Merge data from different nodes

You can use the Merge node to combine data from two previous nodes, even if the workflow hasn't split into separate data streams. This can be useful if you want to generate a single dataset from the data generated by multiple nodes.

![Merging data from two previous nodes. The diagram shows three nodes lined up sequentially. The first node is labeled Fetch data, the second is labeled Modify data, and the third is labeled Merge: append both data sets. Arrows connect nodes 1 to 2, 2 to 3, and 1 to 3.](/_images/flow-logic/merging/merge-node-data.png)
Merging data from two previous nodes

Merge data from multiple node executions

Use the Code node to merge data from multiple node executions. This is useful in some Looping scenarios.

/// note | Node executions and workflow executions This section describes merging data from multiple node executions. This is when a node executes multiple times during a single workflow execution. /// Refer to this example workflow{:target=_blank .external-link} using Loop Over Items and Wait to artificially create multiple executions.

[[ workflowDemo("https://api.n8n.io/workflows/templates/1814") ]]

Compare, merge, and split again

The Compare Datasets node compares data streams before merging them. It outputs up to four different data streams.

Refer to this example workflow{:target=_blank .external-link} for an example.

[[ workflowDemo("https://api.n8n.io/workflows/templates/1943") ]]