Recursive Subarray Flattener with Classification Columns and Sortable Reverse Index
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.Run the manual trigger to emit two fictional items containing nested subarrays
- 2.Truly recursive flattening emits one row per element with source, classification, index and value; items without batch get source UNKNOWN
- 3.An IF node routes empty-string values to a quarantined Set while valid rows pass a flattened Set
- 4.A second path builds one manifest row of batch ids, stage-marked and appended via Merge
- 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
- Import the JSON into n8n and click Execute Workflow
- 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)
- 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
Details
How to Use
- 1.Click "Download Template"
- 2.Open your n8n dashboard
- 3.Go to Workflows > Import from File
- 4.Select downloaded file and configure credentials
Nodes Used (10)
Flatten Demo Trigger
Manual Trigger
Generate Fictional Sample
Code
Recursive Flatten and Index
Code
Row Has Non-Empty Value
If
Mark Flattened Stage
Set
Mark Quarantined Stage
Set
Build Unified Manifest Row
Code
Mark Manifest Stage
Set
Append Both Paths
Merge
Sort Rows and Build Reverse Index
Code
Docs: Pipeline Stages
Sticky Note
Docs: Setup and Replacement
Sticky Note
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