What Base64 is for
Base64 represents binary data using 64 printable ASCII characters, so that bytes can travel safely through text-only channels such as JSON, email (MIME), data URLs and HTTP headers. It increases size by about 33% and is not encryption: anyone can decode it.
Standard vs URL-safe
Standard Base64 uses + and / with = padding. The URL-safe variant (base64url, RFC 4648 §5) swaps them for - and _ and usually drops the padding. It's what JSON Web Tokens use.
Unicode text
The browser's btoa() only accepts Latin-1 characters, so emoji or non-Latin text throws an error. This tool first encodes text as UTF-8 bytes with TextEncoder, which is the correct approach in any language.
// Node.js
Buffer.from('hello', 'utf8').toString('base64')
Buffer.from('aGVsbG8=', 'base64').toString('utf8')
# Python
import base64
base64.b64encode('hello'.encode()).decode()
base64.urlsafe_b64decode('aGVsbG8=')