The Edit Fields (Set) node in **Map Each Item** mode is purpose-built for renaming and restructuring fields.
The Edit Fields (Set) node in Map Each Item mode is purpose-built for renaming and restructuring fields. Reserve Code nodes for logic that genuinely requires JavaScript -- loops with conditionals, external library calls, or algorithmic transforms. Using Edit Fields keeps your workflow visually readable and avoids introducing code maintenance overhead for trivial operations.
Real-world example: An incoming webhook delivers contact data with inconsistent field names from a legacy CRM. You need to normalize them before inserting into a database.
// Incoming data per item:
{
"FIRST_NAME": "Jane",
"LAST_NAME": "Doe",
"EMAIL_ADDR": "jane@example.com",
"PH_NUMBER": "+1-555-0199"
}
```text
Configure the Edit Fields node in **Map Each Item** mode with these assignments:
| Output Field | Expression |
|--------------|-----------------------------|
| `firstName` | `{{ $json.FIRST_NAME }}` |
| `lastName` | `{{ $json.LAST_NAME }}` |
| `email` | `{{ $json.EMAIL_ADDR }}` |
| `phone` | `{{ $json.PH_NUMBER }}` |
Enable **"Include Only Set Fields"** so extraneous fields from the source are dropped.
```json
// Output per item:
{
"firstName": "Jane",
"lastName": "Doe",
"email": "jane@example.com",
"phone": "+1-555-0199"
}
```text
This approach is faster to build, easier to audit, and performs well even at high item counts because it avoids spinning up the Code node sandbox.
**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)
I build production n8n and Cloudflare automation for teams — the same engineering behind HarperFlow. Fixed-price, escrow-protected, US-based.