Following a HTTP request, I get a JSON with loads of fields. The content of one of the fields that I need is encoded in base64. I have NO idea how to decode it! I am a noob in coding, so I have no idea how to use javascript or other to decode the base64. I was hoping maybe to find an API to decode the base64 field, but apart from it being a ridiculous workaround, I also didn’t find any such api services.
Can anybody please help me how to get this done?
I’ve just subscribed for the trial in the hope I can get n8n to work with my basic programming mindset, but minimal coding capacity. Please help me over this hurdle
Decoding base64 is a bit tricky in n8n, but possible. You’d need to run a bit of JS to do so. The basic approach is for example described here, in a workflow it would look like so:
In this example I am using the Function Item node which allows running arbitrary JS code. The example code adds a new memo_text field with the decoded value of each memo_base64 field in your transactions array:
for (transaction of item.transactions) {
// Create a buffer from the base64 string
let bufferObj = Buffer.from(transaction.memo_base64, "base64");
// Encode the Buffer as a utf8 string
let decodedString = bufferObj.toString("utf8");
// Write the result in a new memo_text field
transaction.memo_text = decodedString;
}
return item;
You can also just double click on the Function Item node in my example workflow above to see it (or simply copy the node directly into your own n8n canvas).