Overview
The node, named "Body Mapper," is designed to modify, add, or remove fields in the input data items it receives. It allows users to selectively include or exclude certain fields from the output and to set new or update existing fields with specified values. This node is useful when you want to transform data structures between workflow steps, for example:
- Adding calculated or static fields to enrich data.
- Removing sensitive or unnecessary fields before sending data to another service.
- Restructuring data by renaming or nesting fields using dot notation.
Practical examples:
- Adding a timestamp field to each item.
- Removing internal IDs before exporting data.
- Setting a status field based on some condition.
Properties
| Name | Meaning |
|---|---|
| Input Fields to Include | How to select which fields to include in the output items. Options: - All: Include all unchanged fields from the input. - Selected: Include only the fields listed in the parameter “Fields to Include”. - All Except: Exclude the fields listed in the parameter “Fields to Exclude”. |
| Fields to Set | Edit existing fields or add new ones to modify the output data. Supports multiple entries. Each entry includes: - Key: The name of the field to set (supports dot-notation for nested fields). - Type: The type of the value to set (String, Number, Boolean, Array, Object). - Value: The actual value to assign, matching the selected type. |
Note: The "Fields to Set" property is shown only when the node is in manual mode.
Output
The node outputs an array of items where each item’s json property contains the transformed data according to the configured rules:
- Fields included or excluded based on the "Input Fields to Include" setting.
- Fields added or modified as specified in "Fields to Set".
- Supports nested fields via dot notation.
No binary data output is indicated by the source code.
Dependencies
- No external services or API keys are required.
- The node relies on internal helper modules for field setting logic.
- No special environment variables or n8n credentials are needed.
Troubleshooting
Common issues:
- Incorrect dot notation in field keys may cause unexpected results or no changes.
- Setting a field value with a mismatched type (e.g., entering non-numeric text for a number type) might lead to validation errors or ignored assignments.
- Using expressions incorrectly in object-type fields (starting with "=") requires proper syntax; otherwise, the expression will not be evaluated correctly.
Error messages:
- Validation errors on field values if types do not match expected formats.
- Errors related to missing or invalid parameters if required properties are not set properly.
To resolve these:
- Double-check field names and dot notation syntax.
- Ensure values conform to the selected type.
- Use valid JSON or expression syntax for complex types.
Links and References
- n8n Documentation - Working with Data
- JavaScript Dot Notation and Nested Objects
- n8n Community Forum for user discussions and tips on using the Body Mapper node.