{"id":15154,"library":"node-red-node-base64","title":"Node-RED Base64 Converter Node","description":"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.","status":"maintenance","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/node-red/node-red-nodes","tags":["javascript","node-red","base64"],"install":[{"cmd":"npm install node-red-node-base64","lang":"bash","label":"npm"},{"cmd":"yarn add node-red-node-base64","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-red-node-base64","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This package is a Node-RED node and requires a Node-RED runtime to function.","package":"node-red","optional":false}],"imports":[{"note":"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.","wrong":"import { base64 } from 'node-red-node-base64';","symbol":"base64 node type","correct":"{\"id\": \"my-base64-node\", \"type\": \"base64\", \"name\": \"My Base64 Converter\", \"wires\": [...]} (within Node-RED flow JSON)"},{"note":"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.","wrong":"npm i node-red-node-base64 (run in a standalone project directory or globally)","symbol":"Node-RED node installation","correct":"npm i node-red-node-base64 (run within Node-RED user directory, e.g., ~/.node-red)"},{"note":"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.","wrong":"const encoded = Buffer.from('data').toString('base64'); // Direct Node.js API call, not using the node's functionality","symbol":"Base64 encoding/decoding functionality","correct":"(Configure the 'base64' node in a flow; it automatically detects input type (Buffer for encode, string for decode) from msg.payload)"}],"quickstart":{"code":"// 1. Ensure Node-RED is installed and running.\n// 2. Install the node in your Node-RED user directory (typically ~/.node-red).\n//    Open your terminal and run:\n//    cd ~/.node-red\n//    npm i node-red-node-base64\n// 3. Restart Node-RED if it was running.\n// 4. Open your Node-RED editor (usually at http://localhost:1880).\n// 5. Import the following JSON flow via Menu -> Import -> Clipboard:\n[\n    {\"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\"]]}][\n    // ... (rest of the flow JSON as provided in the README, adjusted for clarity)\n]","lang":"javascript","description":"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."},"warnings":[{"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.","message":"This 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.","severity":"gotcha","affected_versions":">=0.1.0"},{"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.","message":"Node-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.","severity":"gotcha","affected_versions":">=0.1.0"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"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.","cause":"The node package was installed in an incorrect directory or Node-RED was not restarted after installation, preventing the runtime from discovering it.","error":"Error: Can't find node: node-red-node-base64 (or similar 'module not found' messages in Node-RED startup logs)"},{"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.","cause":"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.","error":"TypeError: msg.payload.toString is not a function (or similar errors when handling the output of the base64 node)"}],"ecosystem":"npm"}