base64 — encode or decode base64
SYNOPSIS
base64 [-d] <text...>
DESCRIPTION
Encodes the given <text> to base64, or decodes it with -d. Encoding is UTF-8 aware: accented characters survive an encode → decode round-trip.
OPTIONS
-d, --decode decode the input instead of encoding it
HOW IT WORKS
Base64 represents binary data with 64 printable characters (A–Z, a–z, 0–9, + and /), three bytes becoming four characters, with = as padding. Text is first turned into UTF-8 bytes, so accents and emoji encode and decode correctly, unlike naive browser btoa() calls.
USE CASES
- read an encoded value from an API response, an e-mail or a config file;
- build an HTTP Basic Authorization header (user:password);
- inspect data URLs or Kubernetes secrets.
NOTES
Base64 is an encoding, not encryption: anyone can decode it. The base64url variant used in JWTs replaces + and / with - and _ (see jwt).
EXAMPLES
base64 hello base64 -d aGVsbG8=