Eric Bergman-Terrell's Blog

Node.js Programming Tip: How to Encode and Decode Base64 Text
August 21, 2015

Encoding and decoding Base64 text, in Node.js, is as easy as:

function base64Encode(text) {
    return new Buffer(text).toString('base64');
}

function base64Decode(text) {
    return new Buffer(text, 'base64').toString('utf8');
}

This code is used by my new online Base64 decoder/encoder utility.

For more details about manipulating base 64 data in Node.js, see Hack Sparrow's post.

encoding
What messages are encoded here?

Keywords: Node.js, node, Express, Javascript, Base64, Base 64, Encode, Decode

Reader Comments

Comment on this Blog Post

Recent Posts

TitleDate
Get JetBrains IDEs to Remember Subversion (SVN) CredentialsNovember 3, 2026
Converting a Thinkpad from Windows 11 to Linux MintOctober 29, 2026
Raspberry Pi Camera Trap and Animal Detection ProgramAugust 29, 2026
Python Tip: Fix Incorrect Orientation of Digital PhotosAugust 8, 2026
EBT Weather is now available for Windows and LinuxMay 30, 2026
Node.js + Express: How to Block Requests by User-Agent HeadersJanuary 7, 2026
Vault 3 is Now Available for Windows on ARM Machines!December 13, 2025