This package provides a Node-RED node for encoding and decoding messages using Base64 format. It allows developers to convert `msg.payload` to a Base64 string if the input is a binary buffer, or decode a Base64 string back into a binary buffer. As of its stable `1.0.0` release, it offers robust and straightforward functionality for common Base64 transformations within Node-RED flows. Being part of the official Node-RED nodes collection, it often aligns with Node-RED core updates and feature milestones. Its primary differentiator is its seamless integration into the visual flow programming paradigm of Node-RED, handling the technical details of buffer and string conversions automatically based on input type. The package is maintained, indicating stability with less frequent, but impactful, updates. Its purpose is to simplify Base64 operations for Node-RED users without requiring custom function nodes.
npm install node-red-node-base64Verified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to install the `node-red-node-base64` package and then import a simple Node-RED flow. The flow uses an Inject node to create a Buffer payload, which is then passed to a Base64 node for encoding. The encoded string is debugged, and then passed to another Base64 node for decoding back into a Buffer, with the decoded output also debugged. This showcases the core functionality of converting between binary data and Base64 strings within Node-RED flows.
Access the 'base64' node by dragging it from the palette in the Node-RED editor or by referencing its `type: 'base64'` in Node-RED flow JSON configurations. Do not attempt to `require()` or `import` it in standalone JS files.
Ensure installation is performed using `npm i node-red-node-base64` from within your Node-RED user directory, and restart your Node-RED instance if it was running.
Ensure `msg.payload` is either a `Buffer` (for encoding) or a valid Base64 string (for decoding) before passing it to the Base64 node. Use a preceding `function` node to prepare the payload if necessary.
Navigate to your Node-RED user directory (e.g., `cd ~/.node-red`) and run `npm i node-red-node-base64`. Then, restart your Node-RED instance to reload the palette.
Verify the input type to the Base64 node and, consequently, the expected output type. The node converts `Buffer -> string` and `string -> Buffer`. Adjust subsequent nodes (e.g., `debug` node configuration, `function` node logic) to correctly handle the actual output type.