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 btoa with all npm packages installed. Try it out:

var btoa = require("btoa")

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

btoa v1.1.2

btoa for Node.JS (it's a one-liner)


A port of the browser's btoa function.

Uses Buffer to emulate the exact functionality of the browser's btoa (except that it supports unicode and the browser may not).

It turns binary data to base64-encoded ascii.

(function () {
  "use strict";
  var btoa = require('btoa')
    , bin = "Hello, 世界"
    , b64 = btoa(bin)

  console.log(b64); // "SGVsbG8sIBZM"

Note: Unicode may or may not be handled incorrectly.

Copyright and license

Code and documentation copyright 2012-2014 AJ ONeal Tech, LLC.

Code released under the Apache license.

Docs released under Creative Commons.

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