Base64 vs Base64URL
Base64 turns every 3 bytes into 4 printable characters from A–Z a–z 0–9 + /, padding with =. Base64URL swaps + and / for - and _ and usually drops the padding, so the result is safe inside URLs, file names and JWTs. Base64 is an encoding, not encryption: anyone can decode it.
Component vs full URL encoding
Component (encodeURIComponent) escapes everything that has meaning in a URL, including / ? & = — use it for a single query-string value. Full URL (encodeURI) leaves the URL structure intact and only escapes spaces and non-ASCII characters.
Common uses
- HTTP Basic auth headers:
Authorization: Basic base64(user:password) - Kubernetes Secrets, data URIs, email attachments (MIME)
- Reading the payload of a JWT or a SAML response