HTML BlogCode Manual & Tools

Base64 Encode & Decode Online

Encode text or files to Base64, or decode Base64 strings instantly. All processing happens in your browser.

Text to Encode 0 characters
or upload a file
📎

Drag and drop a file here, or browse

Any file type supported

×
Base64 Output 0 characters
Decoded image preview
Decoded Image Preview

How to Use the Base64 Encoder/Decoder

  1. Choose your mode - Click "Encode" to convert text or files to Base64, or "Decode" to convert Base64 back to readable text.
  2. Enter your data - Type or paste your text into the input field. You can also drag and drop a file onto the upload area when encoding.
  3. Get results instantly - With live mode enabled, the output updates as you type. You can also click the action button manually.
  4. Copy or swap - Use the "Copy Output" button to copy the result to your clipboard, or the "Swap" button to move the output back to the input for further processing.

Tips for Best Results

What is Base64 Encoding?

Base64 is a binary-to-text encoding scheme that represents binary data using a set of 64 ASCII characters. It was designed to allow binary data to be transmitted over channels that only reliably support text content, such as email protocols and HTML documents.

The Base64 alphabet consists of uppercase letters (A-Z), lowercase letters (a-z), digits (0-9), and two additional characters (+ and /). The = character is used for padding when the input length is not divisible by 3.

How Base64 Works

The encoding process takes every 3 bytes (24 bits) of input data and splits them into four groups of 6 bits each. Each 6-bit group is then mapped to one of the 64 characters in the Base64 alphabet. This is why Base64-encoded data is approximately 33% larger than the original.

Original:    M        a        n
ASCII:       77       97       110
Binary:      01001101 01100001 01101110
6-bit groups: 010011 010110 000101 101110
Base64:       T      W        F      u

If the input data is not a multiple of 3 bytes, padding characters (=) are appended to the output to make the total length a multiple of 4.

Common Uses of Base64

Base64 in Web Development

Data URIs in HTML and CSS

Data URIs allow you to embed resources directly in your code. This can reduce HTTP requests and improve page load performance for small assets like icons and simple graphics.

<!-- Embedding an image in HTML -->
<img src="data:image/png;base64,iVBORw0KGgo..." alt="icon">

/* Embedding a background image in CSS */
.icon {
  background-image: url('data:image/svg+xml;base64,PHN2Zy...');
}

While data URIs are convenient, they do increase the size of your HTML/CSS files by about 33%. They are best used for small assets under 5-10 KB. For larger files, separate HTTP requests with proper caching are more efficient.

HTTP Basic Authentication

When accessing a protected API endpoint using Basic Authentication, the credentials are Base64-encoded and included in the request header:

// JavaScript example
const credentials = btoa('username:password');
fetch('https://api.example.com/data', {
  headers: {
    'Authorization': 'Basic ' + credentials
  }
});

Note that Base64 encoding is not encryption. Basic Authentication should always be used over HTTPS to protect credentials in transit.

Email Encoding (MIME)

Email protocols were originally designed for 7-bit ASCII text. To send binary attachments, MIME uses Base64 encoding with lines split at 76 characters. The Content-Transfer-Encoding header indicates Base64 is used:

Content-Type: image/png; name="photo.png"
Content-Transfer-Encoding: base64

iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk
+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==

Frequently Asked Questions

Is Base64 encoding the same as encryption?

No. Base64 is an encoding scheme, not encryption. It transforms binary data into ASCII text for safe transport, but it provides no security. Anyone can decode Base64 data without a key. For security, use proper encryption algorithms like AES or RSA.

Why does Base64 increase the data size?

Base64 encoding increases data size by approximately 33%. This is because it converts every 3 bytes of binary data into 4 ASCII characters. The trade-off is that the resulting data is safe to transmit through text-based protocols that may not handle binary data correctly.

Is my data safe when using this tool?

Yes. All encoding and decoding happens entirely in your browser using JavaScript. No data is ever sent to any server. You can verify this by disconnecting from the internet and using the tool offline - it will continue to work normally.

What is the maximum file size I can encode?

Since all processing happens in your browser, the maximum file size depends on your device's available memory. Most modern devices can handle files up to 50-100 MB without issues. For very large files, consider using a command-line tool like base64 on Linux/macOS or certutil on Windows.

What character sets are supported?

This tool supports UTF-8 (default and recommended), ASCII, ISO-8859-1 (Latin-1), and Windows-1252. UTF-8 is the most widely used encoding on the web and can represent virtually all characters from all writing systems.

Can I decode Base64 images?

Yes. When you decode a Base64 string that contains image data (with a data URI prefix like data:image/png;base64,), the tool automatically detects it and displays an image preview below the output area. You can also paste raw Base64 image data without the prefix.