Decode Base64 encoded string

JavaScript, Node.js, String · Sep 15, 2020

Decodes a string of data which has been encoded using base-64 encoding.

  • Create a Buffer for the given string with base-64 encoding.
  • Use Buffer.prototype.toString() to return the decoded string.
const atob = str => Buffer.from(str, 'base64').toString('binary');

atob('Zm9vYmFy'); // 'foobar'

More like this

  • JavaScript String Snippets

    Master string manipulation in JavaScript with this ES6 snippet collection.

    Collection · 107 snippets

  • Encode string to Base64

    Creates a base-64 encoded ASCII string from a String object in which each character in the string is treated as a byte of binary data.

    JavaScript, Node.js · Sep 15, 2020

  • Introduction to Semantic Versioning (SemVer)

    Learn how semantic versioning works and how to use it to correctly version your software.

    JavaScript, Node.js · Jul 16, 2023

  • Colorize text

    Adds special characters to text to print in color in the console (combined with console.log()).

    JavaScript, Node.js · Nov 3, 2020