Node-RED Base64 Converter Node

1.0.0 · maintenance · verified Tue Apr 21

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.

Common errors

Warnings

Install

Imports

Quickstart

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.

// 1. Ensure Node-RED is installed and running.
// 2. Install the node in your Node-RED user directory (typically ~/.node-red).
//    Open your terminal and run:
//    cd ~/.node-red
//    npm i node-red-node-base64
// 3. Restart Node-RED if it was running.
// 4. Open your Node-RED editor (usually at http://localhost:1880).
// 5. Import the following JSON flow via Menu -> Import -> Clipboard:
[
    {"id":"d2ccae00.2d335","type":"inject","name":"Inject Buffer","topic":"","payload":"","payloadType":"none","repeat":"","crontab":"","once":false,"x":136,"y":99,"z":"385bdf8b.c7a42","wires":[["e03cae10.1fc35"]]},{"id":"b778ef09.48871","type":"base64","name":"Encode to Base64","x":411.5,"y":160,"z":"385bdf8b.c7a42","wires":[["6295d1b1.9d6a3","46b597ba.b94a68"]]},{"id":"6295d1b1.9d6a3","type":"debug","name":"Encoded Output (String)","active":true,"console":"false","complete":"payload","x":610,"y":160,"z":"385bdf8b.c7a42","wires":[]},{"id":"ead9e7c9.152618","type":"debug","name":"Decoded Output (Buffer)","active":true,"console":"false","complete":"payload","x":610,"y":240,"z":"385bdf8b.c7a42","wires":[]},{"id":"46b597ba.b94a68","type":"base64","name":"Decode from Base64","x":411.5,"y":240,"z":"385bdf8b.c7a42","wires":[["ead9e7c9.152618"]]},{"id":"e03cae10.1fc35","type":"function","name":"Create Buffer Payload","func":"msg.payload = Buffer.from("Hello, Node-RED Base64!");\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":160,"z":"385bdf8b.c7a42","wires":[["b778ef09.48871"]]}][
    // ... (rest of the flow JSON as provided in the README, adjusted for clarity)
]

view raw JSON →