Home

Published

- 1 min read

base64 to string and string to base64 javascript decode

img of base64 to string and string to base64 javascript decode

The solution for this is noted below

base64 to string and string to base64 javascript decode

Solution

   // base64 to string
let base64ToString = Buffer.from(obj, 'base64').toString()
base64ToString = JSON.parse(base64ToString)

//or
let str = 'bmltZXNoZGV1amEuY29t'
let buff = new Buffer(str, 'base64')
let base64ToStringNew = buff.toString('ascii')

// string to base64
let data = 'nimeshdeuja.com'
let buff = new Buffer(data)
let stringToBase64 = buff.toString('base64')

Try other methods by searching on the site. That is if this doesn’t work