How to Base64 Encode/Decode in the Terminal/CLI


If you need to either Encode or Decode a Base64 value, there are many ways to achieve this, one of them is directly from your commandline itself!

How to Encode a Base64 value in CLI

echo 'This is a test' | base64

This will output a base64 encoded value of VGhpcyBpcyBhIHRlc3QK

How to Decode a Base64 value in CLI

echo VGhpcyBpcyBhIHRlc3QK | base64 --decode

This will output a decoded value from our base64 value of This is a test