Overview
The Currency Cleaner node is designed to clean and normalize currency fields within JSON input data by removing currency symbols and formatting inconsistencies. This is particularly useful when dealing with financial data imported from various sources where currency values may include symbols (like $, €, £) or inconsistent formatting (commas, spaces). By cleaning these fields, the node prepares the data for further processing, calculations, or integrations that require numeric currency values.
Common scenarios include:
- Preparing sales or invoice data for accounting systems.
- Normalizing amounts before aggregation or reporting.
- Cleaning up imported CSV or JSON data containing currency fields.
Example: If an input JSON has "total_amount": "$1,234.56", after processing, this field would be cleaned to a normalized numeric string like "1234.56".
Properties
| Name | Meaning |
|---|---|
| Fields to Clean | Comma-separated list of JSON field names whose values should be cleaned and normalized. Example: total_amount, vat_amount |
Output
The node outputs the processed items with the specified currency fields cleaned and normalized in their JSON structure. The output maintains the same item structure as the input but with updated values for the targeted fields.
- json: Contains the original input data with the specified currency fields cleaned.
- No binary data output is produced by this node.
Dependencies
- The node depends on an internal helper function (
processItem) imported from a local module (./Helpers) which performs the actual cleaning and normalization logic. - No external API calls or services are required.
- No special credentials or environment variables are needed.
Troubleshooting
- Empty or incorrect field names: If the "Fields to Clean" property is empty or contains field names not present in the input JSON, those fields will simply be ignored without error.
- Malformed currency strings: If a field contains unexpected formats that cannot be parsed, the node may throw an error unless "Continue On Fail" is enabled.
- Error messages: Errors during processing will indicate the item index and the cause. Enabling "Continue On Fail" allows the workflow to continue while capturing errors per item.
- Ensure that the input data is valid JSON and that the fields specified actually contain currency-like strings for meaningful results.
Links and References
- n8n Documentation - Creating Custom Nodes
- General information on currency formatting and parsing can be found in JavaScript number handling guides.