Base64 Encode / Decode
Encode text or files to Base64 and decode Base64 strings back to text or files, entirely in the browser. It runs entirely in your browser — no data is sent to any server, no account required, and it's completely free.
The Complete Guide to Base64 Encoding and Decoding
Base64 is one of the most quietly pervasive technologies on the internet. If you have ever embedded an image in a CSS file, sent an email attachment, handled authentication tokens, or worked with any web API, you have almost certainly encountered Base64 encoding — often without realizing it. In this comprehensive guide, we demystify Base64, explaining how it works, where it is used, and why it remains an essential tool for every developer.
What is Base64 and Why Does It Exist?
Computers fundamentally communicate in binary — sequences of 0s and 1s organized into bytes. However, many older text-based protocols (like SMTP for email, or HTTP in its early forms) were designed to handle only 7-bit ASCII text. When you try to transmit raw binary data (like an image file or a compiled program) through a channel designed only for ASCII text, the bytes that fall outside the printable ASCII range get mangled or stripped entirely.
Base64 solves this problem by converting arbitrary binary data into a safe set of 64 printable ASCII characters: the uppercase letters A-Z, lowercase letters a-z, digits 0-9, and the symbols + and / (with = used as padding). This guarantees that the encoded data can pass through any text-based system without corruption.
How Does Base64 Encoding Work?
The encoding process is elegant and systematic:
- Group bytes into triplets: Take the raw binary input and group the bytes into sets of 3 (24 bits total).
- Split into four 6-bit groups: Each 24-bit triplet is split into four 6-bit groups (since 2⁶ = 64, each group maps to one of the 64 characters).
- Look up the character: Each 6-bit value (0–63) is mapped to its corresponding Base64 character using the Base64 alphabet.
- Padding: If the input is not a multiple of 3 bytes, one or two
=characters are appended as padding to ensure the output length is a multiple of 4.
The result: every 3 bytes of input produce exactly 4 Base64 characters of output, explaining the ~33% size overhead inherent in Base64 encoding.
Where is Base64 Used in the Real World?
1. Email Attachments (MIME)
The MIME (Multipurpose Internet Mail Extensions) standard uses Base64 to encode binary file attachments — images, PDFs, and documents — so they can be safely transmitted as part of a plain-text email message. When you attach a file to a Gmail message, your email client Base64-encodes it before sending.
2. Embedding Images in HTML and CSS
Instead of serving a separate image file (which requires a separate HTTP request), you can embed small images directly into HTML or CSS as a Base64 data URI:
<img src="data:image/png;base64,iVBORw0KGgoAAAANS..." />
This is useful for small icons, loading spinners, and critical above-the-fold images to eliminate render-blocking requests.
3. HTTP Basic Authentication
When a browser sends HTTP Basic Auth credentials, it Base64-encodes the username:password string and sends it in the Authorization header: Authorization: Basic dXNlcjpwYXNz. Importantly, Base64 is encoding, not encryption — it is trivially reversible and provides zero security by itself. Always use HTTPS when transmitting Basic Auth credentials.
4. JSON Web Tokens (JWT)
JWTs consist of three Base64url-encoded segments separated by dots: the header, the payload (claims), and the signature. The "url-safe" variant replaces + with - and / with _ so the token can be safely included in URLs and HTTP headers without URL-encoding.
5. Cryptographic Outputs
Many cryptographic operations (hashing, encryption, digital signatures) produce raw binary output. Base64 is the standard way to represent these outputs as printable strings in configuration files, databases, and API responses.
Base64 vs. URL-Safe Base64
Standard Base64 uses characters (+ and /) that have special meaning in URLs. URL-safe Base64 (also called Base64url) substitutes these with - and _, making the encoded string safe to use in URL query parameters and path segments without requiring percent-encoding.
Security Reminder
Base64 is an encoding scheme, not an encryption scheme. Anyone who receives a Base64-encoded string can decode it instantly. Never use Base64 as a method of securing sensitive data. For actual security, use proper encryption (AES-256) or cryptographic hashing (SHA-256).
Use our free, private Base64 Encoder/Decoder to quickly encode text, decode API tokens, inspect JWTs, and work with data URIs — all processed entirely in your browser.
How to Use the Base64 Encode / Decode
- 1
Choose encode or decode
Select Encode to convert plain text to Base64, or Decode to convert a Base64 string back to text.
- 2
Enter your input
Paste the text or Base64 string you want to convert into the input area.
- 3
Convert and copy
Click Encode or Decode, then copy the output to your clipboard.
Frequently Asked Questions
How do I encode or decode Base64 strings securely online for free?
Our Base64 converter is 100% free and processes everything locally in your browser. This means your sensitive tokens or text never leave your device, ensuring total privacy.
Why does my file size increase when I use a free Base64 encoder?
Base64 encoding naturally expands data by about 33% because 3 bytes of input become 4 characters of output. This is standard and happens instantly in our browser-based tool.
Does this free Base64 tool support URL-safe encoding?
While this tool handles standard Base64 securely, URL-safe Base64 replaces + and / with - and _ to safely pass data in web addresses without requiring an account.
Can I securely encode emojis or Unicode characters to Base64?
Yes! Our free Base64 tool securely handles UTF-8 Unicode, including emojis and complex character sets, right in your browser with zero data sent to external servers.