DEV Community

Pirate Prentice
Pirate Prentice

Posted on

n8n Item Lists Node: Split, Aggregate, Deduplicate, and Sort Your Workflow Data [Free Workflow JSON]

n8n Item Lists Node: Split, Aggregate, Deduplicate, and Sort Your Workflow Data [Free Workflow JSON]

The Item Lists node is one of n8n's most underrated utility nodes. It handles four essential data-shaping operations that would otherwise require a Code node: splitting arrays into individual items, aggregating multiple items back into a single array, removing duplicates, and sorting. If you work with APIs that return arrays, databases that return result sets, or AI nodes that produce lists, you'll use this constantly.

This guide covers all four operations with practical examples and a free workflow JSON at the end.


What the Item Lists Node Does

The node has four distinct operations selectable from a dropdown:

Operation What it does
Split Out Items Turns an array field on one item into N separate items
Aggregate Items Merges N items into one item containing an array
Remove Duplicates Filters items so only unique values remain
Sort Orders items by one or more fields

Each operation is essentially the inverse of another: Split Out ↔ Aggregate. Remove Duplicates and Sort are independent.


Operation 1: Split Out Items

The Problem It Solves

When you call an API, you often get back something like:

{
  "user_id": 42,
  "orders": [
    { "id": "A1", "amount": 99 },
    { "id": "A2", "amount": 150 }
  ]
}
Enter fullscreen mode Exit fullscreen mode

That's one item with an array field. If you want to process each order separately — send a confirmation email per order, write each one to a database row — you need to split the array into individual items first.

Split Out Items does exactly that. Set Field to Split Out to orders and you get two items:

{ "id": "A1", "amount": 99 }
{ "id": "A2", "amount": 150 }
Enter fullscreen mode Exit fullscreen mode

Key Options

  • Field to Split Out: The field path containing the array (e.g., orders, data.results, tags)
  • Include: Choose whether to keep other fields from the source item alongside each split item
    • No Other Fields: only the array element's contents (cleanest for processing)
    • All Other Fields: merges parent fields into each child item (useful for keeping user_id alongside each order)
    • Selected Other Fields: pick specific parent fields to carry forward

Common Use Cases

  • Splitting a Notion database result's tags array into individual tag items
  • Expanding a Google Sheets row with a comma-split field into separate rows
  • Processing each webhook event in a batch payload individually

Watch Out: Arrays of Primitives

If your array contains strings or numbers rather than objects:

{ "emails": ["alice@example.com", "bob@example.com"] }
Enter fullscreen mode Exit fullscreen mode

After splitting, each item will have a field called emails containing a single string. Access it with {{ $json.emails }} — not {{ $json[0] }}.


Operation 2: Aggregate Items

The Problem It Solves

Aggregate is the reverse of Split. You have N items flowing through your workflow and you need to collect them into a single item — usually before calling an API that expects an array body, writing a batch to a database, or passing a list to an AI node.

How to Use It

Set Fields to Aggregate:

  • Field: the field name to pull from each item
  • Rename Field: (optional) name the array field in the output
  • Keep Missing: whether to include items that are missing the field

Example: You have 10 items each with a title field. After aggregating:

{ "title": ["Blog Post 1", "Blog Post 2", "...", "Blog Post 10"] }
Enter fullscreen mode Exit fullscreen mode

You can then pass {{ $json.title }} as the messages body of an API call that expects an array.

Aggregating Multiple Fields

Add multiple entries under Fields to Aggregate to create parallel arrays:

{
  "ids": [1, 2, 3],
  "names": ["Alice", "Bob", "Carol"]
}
Enter fullscreen mode Exit fullscreen mode

This is useful when building bulk API payloads or constructing a structured summary.

The "Aggregate All Item Data" Option

There's a shortcut: set Aggregate to All Item Data (Into a Single List). This wraps every item (in its entirety) into an array under a field you name. Useful for passing a complete item set to a Code node or AI node that processes a list of records.


Operation 3: Remove Duplicates

The Problem It Solves

Deduplication is one of the most common real-world automation needs: remove already-sent leads, skip rows you've already processed, avoid sending duplicate alerts. This operation filters your items so only one copy of each unique value combination remains.

How to Use It

Compare lets you choose what "duplicate" means:

  • All Fields: items are duplicates only if every field matches (strictest)
  • Selected Fields: specify which fields define uniqueness

Example: You have 50 lead records. Some email addresses appear twice (the same lead from two different form submissions). Set Compare to Selected Fields, add email, and only the first occurrence of each email is kept.

Behavior

  • Keeps the first occurrence, removes subsequent duplicates
  • Works on the current set of items in the workflow run (not cross-run memory — for that you'd need a database lookup)
  • Order is preserved for retained items

Cross-Run Deduplication

If you need to deduplicate across workflow runs (e.g., "don't process this webhook event ID twice"), the Item Lists node alone isn't enough — it only sees items in the current execution. Combine it with a database check:

  1. Fetch processed IDs from your DB
  2. Use Merge node to remove already-seen IDs from the current batch
  3. Process the remainder, then write the new IDs back to the DB

Operation 4: Sort

Basic Sorting

Sort your items by any field, ascending or descending.

Example: Sort a list of products by price descending to present the most expensive first.

Options:

  • Field: the field name to sort by (e.g., price, created_at, name)
  • Order: Ascending or Descending
  • Data Type: String, Number, or Date — important for correct ordering (sorting numbers as strings gives wrong results for 10 vs 9)

Multi-Field Sort

Click Add Sort to add secondary (and tertiary) sort keys. Items are sorted by the first key; ties are broken by the second, and so on.

Example: Sort created_at descending, then name ascending for same-date items.

Custom Sort Order

There's a Custom order option: supply an array of values and items will be reordered to match that sequence. Useful for enforcing a specific business priority order that isn't lexicographic.


Practical Workflow: Lead Deduplication + Batch Processing

Here's a real pattern combining all four operations:

  1. HTTP Request — fetch 100 leads from a CRM
  2. Item Lists: Split Out — expand the contacts array into individual items
  3. Item Lists: Remove Duplicates — deduplicate by email
  4. Item Lists: Sort — sort by score descending (highest value leads first)
  5. Item Lists: Aggregate — re-bundle into batches of N for a bulk API call
  6. HTTP Request — POST the deduplicated, sorted, batched lead list to your outreach tool

This pattern converts a raw API dump into a clean, prioritized, deduplicated pipeline in four nodes — no Code node needed.


Free Workflow JSON

This workflow demonstrates all four Item Lists operations with sample data:

{
  "name": "Item Lists: Split, Aggregate, Deduplicate, Sort",
  "nodes": [
    {
      "parameters": {},
      "id": "manual-trigger",
      "name": "Start",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [240, 300]
    },
    {
      "parameters": {
        "jsCode": "return [\n  { json: { user_id: 1, tags: ['n8n','automation','webdev'], score: 85 } },\n  { json: { user_id: 2, tags: ['n8n','javascript'], score: 92 } },\n  { json: { user_id: 3, tags: ['automation','webdev'], score: 85 } },\n  { json: { user_id: 1, tags: ['n8n','automation','webdev'], score: 85 } }\n];"
      },
      "id": "seed-data",
      "name": "Seed Data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [460, 300]
    },
    {
      "parameters": {
        "fieldToSplitOut": "tags",
        "options": { "include": "allOtherFields" }
      },
      "id": "split-tags",
      "name": "Split Out Tags",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 3.2,
      "position": [680, 300]
    },
    {
      "parameters": {
        "operation": "removeDuplicates",
        "compare": "selectedFields",
        "fieldsToCompare": { "fields": [{ "fieldName": "tags" }] }
      },
      "id": "dedup-tags",
      "name": "Remove Duplicate Tags",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 3.2,
      "position": [900, 300]
    },
    {
      "parameters": {
        "operation": "sort",
        "sortFieldsUi": {
          "sortField": [{ "fieldName": "tags", "order": "ascending" }]
        }
      },
      "id": "sort-tags",
      "name": "Sort Tags A to Z",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 3.2,
      "position": [1120, 300]
    },
    {
      "parameters": {
        "operation": "aggregateItems",
        "fieldsToAggregate": {
          "fieldToAggregate": [{ "fieldToAggregate": "tags", "renameField": true, "outputFieldName": "unique_tags" }]
        }
      },
      "id": "aggregate-tags",
      "name": "Aggregate Tag List",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 3.2,
      "position": [1340, 300]
    }
  ],
  "connections": {
    "Start": { "main": [[{ "node": "Seed Data", "type": "main", "index": 0 }]] },
    "Seed Data": { "main": [[{ "node": "Split Out Tags", "type": "main", "index": 0 }]] },
    "Split Out Tags": { "main": [[{ "node": "Remove Duplicate Tags", "type": "main", "index": 0 }]] },
    "Remove Duplicate Tags": { "main": [[{ "node": "Sort Tags A to Z", "type": "main", "index": 0 }]] },
    "Sort Tags A to Z": { "main": [[{ "node": "Aggregate Tag List", "type": "main", "index": 0 }]] }
  }
}
Enter fullscreen mode Exit fullscreen mode

Import this into n8n, run it, and step through each node to see exactly what each operation produces.


Quick Reference

You want to… Use…
Turn an array field into separate items Split Out Items
Collect many items into one array Aggregate Items
Keep only unique records Remove Duplicates
Order items by a field Sort
Deduplicate by one specific field Remove Duplicates → Selected Fields
Sort by multiple criteria Sort → Add Sort (multi-key)

The Item Lists node is one of those nodes you'll add to almost every production workflow. Master these four operations and you'll rarely need a Code node just to reshape data.


The n8n Workflow Starter Pack includes 30+ ready-to-run workflows covering exactly this kind of pattern — grab it at pirateprentice.gumroad.com/l/sxcoe if you want to skip the build-from-scratch phase.

Top comments (1)

Collapse
 
pirateprentice profile image
Pirate Prentice

Which Item Lists operation do you use most — Split Out to unpack nested arrays, Aggregate to collect items back, Remove Duplicates to deduplicate across runs, or Sort to reorder before downstream processing? Drop your use case below — always curious what people are building with these. 🔧