Iconv Lite
AI-generatedOverview
This n8n custom node, Iconv Lite, is designed to convert the character encoding of binary data (such as files) within a workflow. It reads binary data from an input property, decodes it using a specified input encoding, and then re-encodes it with a chosen output encoding. The node also provides options to strip or add a Byte Order Mark (BOM) during conversion.
Common scenarios:
- Converting file encodings between different standards (e.g., from
utf16toutf8). - Preparing files for systems that require specific encodings.
- Cleaning up BOMs from text files before further processing.
- Adding BOMs when exporting files for compatibility.
Practical examples:
- Reading a CSV file in
windows1252encoding and converting it toutf8for downstream processing. - Removing BOM from a UTF-8 encoded file before uploading to a service that does not support BOM.
- Converting legacy documents to modern Unicode formats.
Properties
| Name | Type | Meaning |
|---|---|---|
| Binary Property Input | string | Name of the binary property from which to read the binary data. |
| Binary Property Output | string | Name of the binary property to which the converted binary data will be written. |
| Input Encoding | options | File encoding format of the input data (e.g., utf8, windows1252, base64, etc.). |
| Output Encoding | options | Desired file encoding format for the output data. |
| Strip BOM | boolean | If true, removes the Byte Order Mark (BOM) from the decoded data before re-encoding. |
| Add BOM | boolean | If true, adds a Byte Order Mark (BOM) to the output data after encoding. |
Output
- The node outputs items with their original JSON structure.
- The binary data is written to the specified "Binary Property Output" property.
- The output binary property contains the re-encoded file, preserving the original file name and MIME type if available.
Example output structure:
{
"json": { ... },
"binary": {
"outputPropertyName": {
"data": "<base64-encoded-binary>",
"fileName": "originalFileName.txt",
"mimeType": "text/plain"
}
}
}
- If the operation fails and "Continue On Fail" is enabled, the output item will include an
errorfield with error details.
Dependencies
- External library: iconv-lite (bundled)
- No external API keys or special n8n environment variables are required.
Troubleshooting
Common issues:
- Invalid encoding names: If you specify an unsupported encoding, the node will throw an error.
- Missing binary data: If the specified input binary property does not exist, the item will be skipped.
- Corrupted output: Using incorrect input/output encodings may result in unreadable files.
Error messages:
"Encoding not recognized": Check that both input and output encodings are valid and supported."Cannot read property '...' of undefined": Ensure the input binary property exists on the incoming item."Failed to decode/encode buffer": The binary data may not match the specified input encoding.
How to resolve:
- Double-check the encoding values.
- Make sure the input binary property is set correctly and contains valid data.
- Use "Continue On Fail" to skip problematic items and review errors in the output.