Decoding a base64 string

Hi folks.

I have a base64 string that I wish to decode in a JS node.

My problem is that we cannot use atob or Buffer in the JS nodes.

Has anyone gotten around this yet?

Here is my code so far:

var base64String = inputs.input1.result;
var base64Cleaned = base64String.replace(/-/g, '+').replace(/_/g, '/');

var jsonPayload = decodeURIComponent(atob(base64Cleaned).toString().split('').map(function(c) {
    return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);

return { result: JSON.parse(jsonPayload)};


Hi Richard,

there are 2 flow functions regarding base64, but as you are advanced with JS, you can also write custom code in the ‘Javascript’ node.


Thank you @stayfoolish

I am not dealing with a file. Just a base64 string that needs to be decoded into a JSON object so I don’t see how the file flow functions can help there.

The Javascript node doesn’t work is it is most likely a cut down version and seems not to have access to the required functions to make the code work as described above.

@Richard_Soderblom, check out this thread on Stack Overflow for a solution without Buffer:

1 Like

Awesome. Thank you @Mari

I will give it a shot this weekend.

Richard, did that work?

Sorry for not updating earlier.

The solution worked perfectly.

I incorporated it into a bit of code that could decode JWT tokens as well with success.

I’m using JWT as well, but I don’t need to decode them. My node.JS backend is decrypting as needed, mostly in my auth route.
Haven’t done anything with JS inside AG.