Skip to content
AI Agents

Recursive Subarray Flattener with Classification Columns and Sortable Reverse Index

10 nodes 99 7 Manual trigger
Download

Loading workflow…

Workflow Description

A fully local manual workflow that generates two fictional items with nested subarrays under keys and objects, recursively flattens them at any depth (including batches.inner), promotes each array key path into a classification column with its original numeric index, quarantines empty values via IF with Set stage markers, merges the flatten path with a unified manifest path using append-mode Merge, then builds one deterministic sorted report with a reverse index using an explicit '(empty)' key for blank values and an unknown_source_rows counter exposing rows from items missing a batch id.

How it works

  1. 1.Run the manual trigger to emit two fictional items containing nested subarrays
  2. 2.Truly recursive flattening emits one row per element with source, classification, index and value; items without batch get source UNKNOWN
  3. 3.An IF node routes empty-string values to a quarantined Set while valid rows pass a flattened Set
  4. 4.A second path builds one manifest row of batch ids, stage-marked and appended via Merge
  5. 5.A final Code node sorts rows stably, assigns row ids, keys blank values as (empty) and counts UNKNOWN-source rows

Use cases

  • Flattening nested webhook payloads before resending
  • Tracing any row back to its parent array and original position at any nesting depth
  • Combining multiple branch outputs into one inspectable sortable report

Requirements

  • No credentials required; fully local processing
  • For production: replace the sample node with a Webhook output using the same schema (batch field as parent id)

Setup and testing in n8n

  1. Import the JSON into n8n and click Execute Workflow
  2. Verify a single final report with 9 sorted rows including R001 from batches.inner and a reverse index where the blank value appears under (empty)
  3. Edge case: remove the batch field from one sample item and confirm source=UNKNOWN with unknown_source_rows=1 without failure

Service Value

Ready-made workflow template for automation delivery and service execution.

Apps Used

Manual Trigger Code If Set Merge

Details

Trigger Manual trigger
Nodes 10
Apps 5
Views 99
Downloads 7

How to Use

  1. 1.Click "Download Template"
  2. 2.Open your n8n dashboard
  3. 3.Go to Workflows > Import from File
  4. 4.Select downloaded file and configure credentials

Nodes Used (10)

/

Flatten Demo Trigger

Manual Trigger

#1

Generate Fictional Sample

Code

#2

Recursive Flatten and Index

Code

#3

Row Has Non-Empty Value

If

#4

Mark Flattened Stage

Set

#5

Mark Quarantined Stage

Set

#6

Build Unified Manifest Row

Code

#7

Mark Manifest Stage

Set

#8

Append Both Paths

Merge

#9

Sort Rows and Build Reverse Index

Code

#10

Docs: Pipeline Stages

Sticky Note

#11

Docs: Setup and Replacement

Sticky Note

#12
Stay in the loop

Fresh workflows, straight to your inbox

Get newly published DROPIDEA workflows, a clear overview of what they do, and a link to explore them.

  • New workflows
  • Clear overviews
  • Setup guides

Be first to discover what is new

Your name, your email, and one confirmation.

Email confirmation · Unsubscribe anytime