Flatten Variable Key/Value Pairs into Long Label/Value Rows per Deal
Loading workflow…
Workflow Description
A manual-trigger workflow that converts a nested CRM deals payload with a variable number of key/value pairs into long rows with four fixed columns: deal_id, dot-path field label, value, and source array. Nested objects are flattened to dot paths; every pair (including deal_id itself) becomes its own row; a Set node normalizes the final columns; empty-valued rows are split by an If node, tagged, and merged back with filled rows, so the total of 14 rows equals the flattened pair count.
How it works
- 1.Manual Trigger starts execution with an empty item
- 2.A Code node emits a fictional demo payload of two deals with fully different keys
- 3.A Code node flattens each deal into one row per key/value pair (deal_id included) with dot-path flattening
- 4.A Set node normalizes the four final columns
- 5.An If node splits empty-valued rows from filled ones
- 6.Two Set nodes tag rows as filled or empty_value
- 7.A Merge node in append mode recombines both branches; a NoOp is the final checkpoint
Use cases
- Normalizing CRM deals with variable keys before reports or spreadsheets
- Flattening nested JSON payloads into a repeatable fixed-column shape
- Data quality checks by isolating empty fields
Requirements
- No credentials needed; fully local execution
- For real data, replace the demo payload Code node with CRM/HTTP output using schema deals: [...]
Setup and testing in n8n
- Import the JSON into n8n and run the Manual Trigger
- Verify 14 output rows (7 per deal, including the field_label=deal_id rows) with fixed columns and stage/notes/probability/region tagged empty_value
- Try a payload with completely different keys; columns stay fixed and row count equals the flattened pair count
- Test an empty payload or a deal with no pairs; the workflow must not fail
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 (9)
Manual Trigger
Manual Trigger
Sample CRM Deals Payload
Code
Flatten Each Deal into Long Rows
Code
Normalize Final Columns
Set
Is Value Filled?
If
Tag Filled Rows
Set
Tag Empty Rows
Set
Append Filled and Empty Rows
Merge
Final Checkpoint
No Op
Docs - Fixed Row Schema
Sticky Note
Docs - Routing and Merge
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