Base64 encoder: what it is and how it works
Base64 is an encoding scheme that converts binary data into ASCII text using 64 characters (A-Z, a-z, 0-9, + and /). It is not encryption — anyone can decode it — but a way to transmit binary data through channels that only accept text.
Main uses of Base64
- Embedding images in HTML/CSS as Data URLs (avoids additional HTTP requests).
- Email attachments in MIME format.
- Authentication tokens in HTTP headers (Authorization: Basic).
- Storing binary data in JSON or XML.
- Passing complex data as URL parameters.
Base64 vs. URL-safe Base64
Standard Base64 uses + and / which have special meaning in URLs. URL-safe Base64 replaces + with - and / with _ to be used directly in URLs and filenames without additional encoding. JWT (JSON Web Tokens) uses URL-safe Base64.
Output size
Base64 increases data size by approximately 33%. That is why it should not be used for all data, only when necessary for compatibility. For large data, direct binary transfer is more efficient.