Registry / serialization / node-red-node-base64

node-red-node-base64

JSON →
library1.0.0jsnpmunverified

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-base64
INSTALL
IMPORT
SIG · NODE-RED-NODE-BASE
N
node-red-node-base64
serializationjavascriptv1.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

base64 node type
{"id": "my-base64-node", "type": "base64", "name": "My Base64 Converter", "wires": [...]} (within Node-RED flow JSON)
import { base64 } from 'node-red-node-base64';
This package is a Node-RED node; its functionality is accessed by adding a 'base64' node to a flow in the Node-RED editor, or by referencing its type 'base64' in flow JSON. It does not provide JavaScript/TypeScript exports for direct programmatic use in application code.
Node-RED node installation
npm i node-red-node-base64 (run within Node-RED user directory, e.g., ~/.node-red)
npm i node-red-node-base64 (run in a standalone project directory or globally)
Node-RED nodes must be installed in the Node-RED user directory to be discovered and loaded by the Node-RED runtime. Standard project installations or global installations will not make the node available in the Node-RED palette.
Base64 encoding/decoding functionality
(Configure the 'base64' node in a flow; it automatically detects input type (Buffer for encode, string for decode) from msg.payload)
const encoded = Buffer.from('data').toString('base64'); // Direct Node.js API call, not using the node's functionality
The node provides a visual, flow-based interface for Base64 operations, abstracting away the need for direct programmatic calls to Node.js's native Buffer methods within function nodes.

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) ]
Debug
Known issues
gotchaThis package is exclusively a Node-RED node and is not designed for direct programmatic import or use in standard JavaScript/TypeScript applications. Its functionality is exposed solely within the Node-RED runtime and editor.
fix
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.
affects: >=0.1.0
gotchaNode-RED nodes must be installed specifically within the Node-RED user directory (typically `~/.node-red`) for the runtime to discover and load them. Installing the package globally or as a regular project dependency will not make it available in the Node-RED palette.
fix
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.
affects: >=0.1.0
gotchaThe Base64 node automatically determines whether to encode or decode based on the input `msg.payload`'s type. If the payload is a `Buffer`, it encodes to a string. If it's a Base64-encoded string, it decodes to a `Buffer`. Supplying other types may result in no action or unexpected behavior.
fix
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.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Can't find node: node-red-node-base64 (or similar 'module not found' messages in Node-RED startup logs)
The node package was installed in an incorrect directory or Node-RED was not restarted after installation, preventing the runtime from discovering it.
fix
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.
TypeError: msg.payload.toString is not a function (or similar errors when handling the output of the base64 node)
The output type from the Base64 node (Buffer or string) was not what a subsequent node expected. For example, trying to call string methods on a Buffer, or Buffer methods on a string.
fix
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.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
node-redrequiredThis package is a Node-RED node and requires a Node-RED runtime to function.
Agent activity
6 hits · last 30 days
node
6
Resources
node-red-node-base64 — npm install node-red-node-base64 · libregistry