Base64 for Node.js - Encode and decode using base64 in Node.js
The ultimate shortcut for the base64 encode/decode functions in Node.js.
TypeScript types available.
Usage
const { base64encode, base64decode } = require('nodejs-base64');
let encoded = base64encode('hey there'); // "aGV5IHRoZXJl"
let decoded = base64decode(encoded); // "hey there"
Installation
Install from command line:
npm i --save nodejs-base64
Requirements
Tested on Node 18, 20, 22, 24 and 26. Encoding accepts a string or number and always returns a string. Decoding returns UTF-8 text and follows Node's permissive Base64 decoding rules, including whitespace and URL-safe input.