What Base64 is for
Base64 turns any bytes into plain text using 64 safe characters, so binary data can travel through systems that only handle text: JSON fields, HTTP headers, email and URLs. It is an encoding, not encryption. Anyone can decode it.
Base64 vs Base64URL
Standard Base64 uses + and / and pads the end with =. Those characters have special meaning in URLs, so Base64URL replaces them with - and _ and usually drops the padding. JWTs and many OAuth parameters use Base64URL. This tool decodes both automatically.
Basic auth headers
HTTP Basic authentication sends username:password encoded as Base64. To build the header, encode apiuser:secret and send Authorization: Basic YXBpdXNlcjpzZWNyZXQ=. Because Base64 is reversible, only send Basic auth over HTTPS.
Unicode and the btoa error
In JavaScript, btoa("₹") throws “The string to be encoded contains characters outside of the Latin1 range.” Encode the text as UTF-8 bytes first:
// Browser and Node 16+
const bytes = new TextEncoder().encode("Price: ₹499");
const b64 = btoa(String.fromCharCode(...bytes));
// Node.js
Buffer.from("Price: ₹499", "utf8").toString("base64"); In Java, use Base64.getEncoder().encodeToString(text.getBytes(StandardCharsets.UTF_8)), or getUrlEncoder().withoutPadding() for Base64URL.