Convert a string to base64

To base64 encode your string on the command-line:

$ base64 <<< 'your string'

However, this includes the newline at the end. To encode without the newline, use printf:

$ printf 'your string' | base64

For those on Mac, use pbcopy to copy the output to your clipboard:

$ printf 'your string' | base64 | pbcopy

If you don’t have base64 installed, you can try an alternative:

$ printf 'your string' | openssl base64

And you can always encode the string in the browser’s JavaScript console:

btoa('your string');

Or use