What is Base64?
Base64 is a binary-to-text encoding scheme that represents binary data using 64 printable ASCII characters (A–Z, a–z, 0–9, + and /). It was designed to safely transmit binary data over channels that only reliably handle text — like email (SMTP) and early HTTP.
The encoding works by taking 3 bytes (24 bits) of input and mapping them to 4 Base64 characters (6 bits each). This means Base64-encoded output is roughly 33% larger than the original input. Padding characters (=) are added if the input isn't a multiple of 3 bytes.
Common Uses of Base64 Encoding
- Data URIs – Embed images directly in HTML/CSS as
data:image/png;base64,...to eliminate HTTP requests. - API payloads – Encode binary files (PDFs, images) for safe transport inside JSON responses.
- HTTP Basic Auth – Credentials are Base64-encoded before being placed in the
Authorizationheader. - Email attachments – MIME multipart encoding uses Base64 for all non-text attachments.
- JWT tokens – JSON Web Token headers and payloads are Base64url-encoded (a URL-safe variant without
+or/). - Environment variables – Encoding binary secrets (private keys, certificates) for storage in
.envfiles.
Base64 is Encoding, Not Encryption
A common misconception is that Base64 provides security. It does not. Base64 is trivially reversible — any encoded string can be decoded back to the original in milliseconds. It is a data format, not a security measure. Never use Base64 as a substitute for encryption. For secure storage of sensitive data, use proper encryption algorithms.
Frequently Asked Questions
Is Base64 encoding the same as encryption?
No. Base64 is a reversible encoding scheme with no key or secret. Anyone can decode a Base64 string in seconds. Never use it to "hide" sensitive data.
What is URL-safe Base64?
Standard Base64 uses + and / which have special meaning in URLs. URL-safe Base64 replaces them with - and _. This variant is used in JWTs and many API systems.
Why does Base64 output end with == sometimes?
Base64 encodes 3 bytes into 4 characters. If the input length isn't a multiple of 3, one or two = padding characters are appended to make the output length a multiple of 4.
Can I encode images with this tool?
This tool encodes and decodes text strings. For embedding images as data URIs, you would need to encode the binary file data — use the browser's FileReader API or a dedicated file-to-Base64 tool.