How to create Base64 encode/decode Strings in Node.js?

Today, I gonna show you guys how we can encode and decode (Base64) the string in Node.js project. First, you need to create the Node server and copy the below codes to server.js for the testing.

const encodedString = Buffer.from(“Hello Node”).toString(‘base64’);

const decodedString = Buffer.from(“SGVsbG8gTm9kZQ==”, ‘base64’).toString(‘ascii’);

That’s it. I hope this will help. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *