How to encode and decode Base64 on a Mac

Encode or decode Base64 on a Mac with the built-in base64 command, for text or whole files, or from the MacBook notch without opening Terminal.

By Rudra Satani, maker of NotchMind ·

Base64 turns text or files into plain ASCII so they can travel through places that only accept text, like JSON, email or a URL. macOS has a tool for it built in.

Text, in Terminal

Encode:

echo -n 'hello world' | base64

The -n matters: without it, echo adds a newline that ends up in the result.

Decode:

echo 'aGVsbG8gd29ybGQ=' | base64 -D

Files, in Terminal

base64 -i photo.png -o photo.txt
base64 -D -i photo.txt -o photo-copy.png

The clipboard

pbpaste | base64 | pbcopy
pbpaste | base64 -D | pbcopy

From the notch

NotchMind, which I make, has Base64 encode and Base64 decode on its Developer Tools page in the notch. Paste, press the arrow, and copy the result. It handles UTF-8 text, so accented letters and emoji round-trip correctly, and it runs on your Mac. See developer tools in the notch.

Base64 isn’t encryption

Anyone can decode it. Don’t use it to hide passwords or keys.

About the author

Rudra Satani makes NotchMind, a notch app for Mac, so read anything about notch apps here with that in mind. Spotted a mistake? Email support@notchmind.com, or reach out at @rudraxx13.