Tips > Data, APIs & Webhooks

Chain Multiple Edit Fields Nodes Instead of One Complex Code Node

When a transformation involves several distinct steps -- renaming, filtering, computing derived fields -- resist the urge to pack it all into one Code node.

TipIntermediate2 min read

When a transformation involves several distinct steps -- renaming, filtering, computing derived fields -- resist the urge to pack it all into one Code node. Instead, chain multiple Edit Fields nodes, each handling one logical step. This produces a visual pipeline that is self-documenting, easier to debug (you can inspect output at each stage), and maintainable by team members who do not write JavaScript.

Real-world example: An e-commerce webhook delivers raw order data that needs: (1) field renaming, (2) currency conversion, (3) status mapping, and (4) output trimming.

Workflow structure:

[Webhook] → [Rename Fields] → [Convert Currency] → [Map Status] → [Trim Output]
```text
**Node 1 -- Rename Fields** (Edit Fields):

| Output Field   | Expression                       |
|----------------|----------------------------------|
| `orderId`      | `{{ $json.order_ref }}`          |
| `customerEmail`| `{{ $json.cust_email }}`         |
| `rawAmount`    | `{{ $json.total_cents }}`        |
| `rawStatus`    | `{{ $json.order_status_code }}`  |

**Node 2 -- Convert Currency** (Edit Fields):

| Output Field    | Expression                                |
|-----------------|-------------------------------------------|
| `amountUSD`     | `{{ ($json.rawAmount / 100).toFixed(2) }}`|
| *(keep others)* | *(Include All Other Fields enabled)*      |

**Node 3 -- Map Status** (Edit Fields):

| Output Field | Expression                                                                                      |
|--------------|-------------------------------------------------------------------------------------------------|
| `status`     | `{{ {"1":"pending","2":"processing","3":"shipped","4":"delivered"}[$json.rawStatus] \|\| "unknown" }}` |

**Node 4 -- Trim Output** (Edit Fields, Include Only Set Fields):

| Output Field   | Expression                 |
|----------------|----------------------------|
| `orderId`      | `{{ $json.orderId }}`      |
| `customerEmail`| `{{ $json.customerEmail }}`|
| `amountUSD`    | `{{ $json.amountUSD }}`    |
| `status`       | `{{ $json.status }}`       |

Each node has a clear purpose visible from its name. When something breaks, you click the failing node and immediately see its input and output -- no reading through 40 lines of JavaScript.

**Related:** [Flatten Deeply Nested API Responses](../code-node-mastery/01-flatten-deeply-nested-api-responses.md) | [Use the HTTP Request Node as a Universal Connector](../integration-patterns/01-use-the-http-request-node-as-a-universal-connector.md)

Want this running in your stack?

I build production n8n and Cloudflare automation for teams — the same engineering behind HarperFlow. Fixed-price, escrow-protected, US-based.