🌐
npm
npmjs.com › package › base-64
base-64 - npm
October 17, 2020 - A robust base64 encoder/decoder that is fully compatible with `atob()` and `btoa()`, written in JavaScript.. Latest version: 1.0.0, last published: 6 years ago. Start using base-64 in your project by running `npm i base-64`. There are 1778 other ...
      » npm install base-64
    
Published: Oct 17, 2020
Version: 1.0.0
🌐
npm
npmjs.com › package › js-base64
js-base64 - npm
2 weeks ago - Yet another Base64 transcoder in pure-JS. Latest version: 3.9.4, last published: 12 days ago. Start using js-base64 in your project by running `npm i js-base64`. There are 4095 other projects in the npm registry using js-base64.
      » npm install js-base64
    
Published: Sep 19, 2026
Version: 3.9.4
🌐
npm
npmjs.com › package › Base64
Base64 - npm
Base64 encoding and decoding. Latest version: 1.3.0, last published: 3 years ago. Start using Base64 in your project by running `npm i Base64`. There are 156 other projects in the npm registry using Base64.
      » npm install Base64
    
Published: Sep 18, 2023
Version: 1.3.0
🌐
npm
npmjs.com › package › base64-js
base64-js - npm
November 11, 2020 - Base64 encoding/decoding in pure JS. Latest version: 1.5.1, last published: 6 years ago. Start using base64-js in your project by running `npm i base64-js`. There are 3297 other projects in the npm registry using base64-js.
      » npm install base64-js
    
Published: Nov 11, 2020
Version: 1.5.1
🌐
npm
npmjs.com › package › nodejs-base64
nodejs-base64 - npm
April 18, 2021 - Latest version: 2.0.0, last published: 5 years ago. Start using nodejs-base64 in your project by running `npm i nodejs-base64`. There are 55 other projects in the npm registry using nodejs-base64.
      » npm install nodejs-base64
    
Published: Apr 18, 2021
Version: 2.0.0
🌐
npm
npmjs.com › package › base64-string
base64-string - npm
May 10, 2024 - Encode text to base64url, as per RFC-4648.
      » npm install base64-string
    
Published: May 10, 2024
Version: 1.1.3
Starred by 5 users
Forked by 2 users
Languages: JavaScript
🌐
npm
npmjs.com › package › hi-base64
hi-base64 - npm
July 8, 2026 - Encode string to base64, set asciiOnly to true for better performace.
      » npm install hi-base64
    
Published: Jul 08, 2026
Version: 0.5.0
🌐
npm
npmjs.com › package › react-native-base64
react-native-base64 - npm
September 21, 2025 - Base64 encoding and decoding helping util. Created for React Native but can be used anywhere. Latest version: 0.2.2, last published: a year ago. Start using react-native-base64 in your project by running `npm i react-native-base64`. There are 121 other projects in the npm registry using react-native-base64.
      » npm install react-native-base64
    
Published: Sep 21, 2025
Version: 0.2.2
🌐
npm
npmjs.com › package › @jsonjoy.com › base64
@jsonjoy.com/base64 - npm
4 weeks ago - High-performance Base64 encoder and decoder. Latest version: 18.30.0, last published: 24 days ago. Start using @jsonjoy.com/base64 in your project by running `npm i @jsonjoy.com/base64`. There are 4 other projects in the npm registry using @jsonjoy.com/base64.
      » npm install @jsonjoy.com/base64
    
Published: Sep 08, 2026
Version: 18.30.0
Find elsewhere
🌐
npm
npmjs.com › package › is-base64
is-base64 - npm
March 4, 2020 - Predicate that returns true if base64 string.. Latest version: 1.1.0, last published: 6 years ago. Start using is-base64 in your project by running `npm i is-base64`. There are 740 other projects in the npm registry using is-base64.
      » npm install is-base64
    
Published: Mar 04, 2020
Version: 1.1.0
🌐
npm
npmjs.com › search
base64 - npm search
A C++ module for node-js that does base64 encoding and decoding.
🌐
npm
npmjs.com › package › @hexagon › base64
@hexagon/base64 - npm
Encode, decode and validate base64/base64url to string/arraybuffer and vice-versa.
      » npm install @hexagon/base64
    
Published: Oct 18, 2024
Version: 2.0.4
🌐
npm
npmjs.com › package › base64-encoding
base64-encoding - npm
Latest version: 0.15.0-alpha.0, last published: 4 years ago. Start using base64-encoding in your project by running `npm i base64-encoding`. There are 3 other projects in the npm registry using base64-encoding.
      » npm install base64-encoding
    
Published: Apr 05, 2022
Version: 0.15.0-alpha.0
Author: Florian Klampfer
Top answer
1 of 8
2832

Buffers can be used for taking a string or piece of data and doing Base64 encoding of the result. For example:

> console.log(Buffer.from("Hello World").toString('base64'));
SGVsbG8gV29ybGQ=
> console.log(Buffer.from("SGVsbG8gV29ybGQ=", 'base64').toString('ascii'))
Hello World

The Buffer constructor is a global object, so no require is needed. Buffers created with strings can take an optional encoding parameter to specify what encoding the string is in. The available toString and Buffer constructor encodings are as follows:

'ascii' - for 7 bit ASCII data only. This encoding method is very fast, and will strip the high bit if set.

'utf8' - Multi byte encoded Unicode characters. Many web pages and other document formats use UTF-8.

'ucs2' - 2-bytes, little endian encoded Unicode characters. It can encode only BMP(Basic Multilingual Plane, U+0000 - U+FFFF).

'base64' - Base64 string encoding.

'binary' - A way of encoding raw binary data into strings by using only the first 8 bits of each character. This encoding method is deprecated and should be avoided in favor of Buffer objects where possible. This encoding will be removed in future versions of Node.

2 of 8
402

The accepted answer previously contained new Buffer(), which is considered a security issue in Node.js versions greater than 6 (although it seems likely for this use case that the input can always be coerced to a string).

The Buffer constructor is deprecated according to the documentation.

The code snippets should read:

console.log(Buffer.from("Hello World").toString('base64'));
console.log(Buffer.from("SGVsbG8gV29ybGQ=", 'base64').toString('ascii'));

After this answer was written, it has been updated and now matches this.

🌐
npm
npmjs.com › package › @types › base-64
@types/base-64 - npm
TypeScript definitions for base-64. Latest version: 1.0.2, last published: 2 years ago. Start using @types/base-64 in your project by running `npm i @types/base-64`. There are 78 other projects in the npm registry using @types/base-64.
      » npm install @types/base-64
    
🌐
npm
npmjs.com › package › nodejs-base64-encode
nodejs-base64-encode - npm
Simple Node Js Package For Encode Decode A Given String. Latest version: 1.1.0, last published: 7 years ago. Start using nodejs-base64-encode in your project by running `npm i nodejs-base64-encode`. There are 14 other projects in the npm registry ...
      » npm install nodejs-base64-encode
    
Published: Feb 16, 2020
Version: 1.1.0
🌐
npm
npmjs.com › package › @juanelas › base64
@juanelas/base64 - npm
Base64 for both node.js and browser javascript. It supports URL-safe encoding and enabling/disabling padding. Buffers can be implementedd using ArrayBuffer, any TypedArray, or Buffer. Latest version: 1.1.5, last published: 3 years ago. Start using @juanelas/base64 in your project by running `npm i @juanelas/base64`. There are 11 other projects in the npm registry using @juanelas/base64.
      » npm install @juanelas/base64
    
Published: Nov 10, 2023
Version: 1.1.5
🌐
Npm
npm.io › search › keyword:base64
Base64 | npm.io
A robust base64 encoder/decoder that is fully compatible with `atob()` and `btoa()`, written in JavaScript.
🌐
npm
npm.io › home › base-64
base-64 | npm.io
October 17, 2020 - A robust base64 encoder/decoder that is fully compatible with atob() and btoa() , written in JavaScript.
Published: May 13, 2014
Version: 1.0.0
Author: Mathias Bynens