Base64Decode Function

The Base64Decode function converts a Base64 value to the string value (human readable value). Base64 is an encoding scheme used to represent binary data in an ASCII format. It is useful when binary data needs to be sent over media that are usually designed to handle textual data. Similar functions are Base64Encode and StringToHex.



1 = Base64 text value (can be a variable)
2 = Character set for encoding. Defaults to UTF-8 but can use UTF-16
3 = If used in a send, a 0 value continues the send in an error and a 1 value stops the send. Defaults to 1.




var @base64
set @base64 = “QmFzZTY0IGVuY29kaW5nIG9mIGEgc3RyaW5n”
%%=Base64Decode(@base64, “UTF-8”, 1)=%%



Base64 encoding of a string


In the AMPscript above, first we are declaring the variables using the var function. Then defining the @base64 variable as the actual base64 text: “QmFzZTY0IGVuY29kaW5nIG9mIGEgc3RyaW5n”

The base64 text is the binary-to-text encoding that represents binary data in a sequence of 8-bit bytes. The output is the string value of “Base64 encoding of a string”

If you were to use the Base64Encode function on the output above, it would give you the same base64 value in the @base64 variable.

Leave a Reply

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