Overview
The "Text File Tools" node processes text-based files contained in binary data within n8n workflows. It is designed to manipulate the content of text files by performing common text transformations such as removing the UTF-8 Byte Order Mark (BOM), converting line endings between Unix and Windows formats, and skipping a specified number of lines from the start of the file.
This node is beneficial when working with text files that need normalization or cleanup before further processing, for example:
- Removing BOM characters that can cause issues in parsers.
- Converting line endings to match the target system's expectations (e.g., converting LF to CRLF for Windows compatibility).
- Skipping header lines or metadata lines at the beginning of a file before parsing the main content.
Practical examples include preparing CSV or log files for import, cleaning up text exports from different operating systems, or preprocessing text data for analysis.
Properties
Name | Meaning |
---|---|
Binary Property Name | The name of the binary property containing the text file to process (default: "data"). |
Strip UTF-8 BOM | Whether to remove the UTF-8 Byte Order Mark (BOM) if present at the start of the file. |
Convert Line Endings | Enable conversion of line endings between LF (Unix) and CRLF (Windows). |
Line Ending Conversion | Choose how to convert line endings when enabled: "LF to CRLF (Unix → Windows)" or "CRLF to LF (Windows → Unix)". |
Skip First N Lines | Enable skipping the first N lines of the text file. |
Number of Lines to Skip | Specify how many lines to skip from the start of the file (minimum 1). |
Output
The node outputs the processed text file as binary data under the same binary property name specified in the input. The output binary data contains the transformed text encoded in UTF-8 and base64 format.
The json
output field is empty ({}
) because this node focuses on transforming binary text data rather than producing JSON content.
If the input binary data is missing or invalid for the specified property, the node throws an error unless configured to continue on failure.
Dependencies
- No external services or APIs are required.
- The node operates entirely on binary data provided within the workflow.
- Requires proper configuration of the binary property name to locate the text file data.
Troubleshooting
Error: No binary data found for property "X"
This occurs if the specified binary property does not exist in the input item or contains no data. Ensure the correct binary property name is set and that the input contains valid binary data.Incorrect line ending conversions
Verify that the "Convert Line Endings" option is enabled and the correct conversion direction is selected based on your source and target environments.Unexpected file content after skipping lines
Confirm the number of lines to skip is appropriate and that the "Skip First N Lines" option is enabled only when needed.UTF-8 BOM not removed
Make sure the "Strip UTF-8 BOM" option is enabled; otherwise, the BOM will remain intact.
Links and References
- UTF-8 Byte Order Mark (BOM) - Wikipedia
- Line ending conventions - Wikipedia
- Node.js Buffer Documentation (for understanding base64 and UTF-8 encoding)