Home » Javascript, Node.js14 August 2018

Base64 encode/decode in Nodejs and Javascript

This article shows how you can base64 encode and decode string using both Nodejs and Javascript.

Javascript: Base64 encode/decode string

Encode String

btoa() function creates a base-64 encoded ASCII string from the given String object.

Decode String

atob() function decoded the base-64 encoded string.

Nodejs: Base64 encode/decode string

Node.js uses Buffer object to encode/decode string. Buffer is a global object. Hence, we don’t have to include/require it separately. It’s available by default.

Encode String

Decode String

Hope this helps. Thanks.

Node.js

Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed