Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including base64-js with all npm packages installed. Try it out:

var base64Js = require("base64-js")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

base64-js v1.3.0

Base64 encoding/decoding in pure JS


base64-js does basic base64 encoding/decoding in pure JS.

build status

testling badge

Many browsers already have base64 encoding/decoding functionality, but it is for text data, not all-purpose binary data.

Sometimes encoding/decoding binary data in the browser is useful, and that is what this module does.


With npm do:

npm install base64-js and var base64js = require('base64-js')

For use in web browsers do:

<script src="base64js.min.js"></script>


base64js has three exposed functions, byteLength, toByteArray and fromByteArray, which both take a single argument.

  • byteLength - Takes a base64 string and returns length of byte array
  • toByteArray - Takes a base64 string and returns a byte array
  • fromByteArray - Takes a byte array and returns a base64 string



RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free