Base64 Encoder & Decoder Online

Convert Text、Files or Images to Base64 Online - Supports Both Encoding and Decoding

Input

Output

Understanding Base64 Encoding

Learn about Base64 encoding, its applications, and implementation in different environments.

What is Base64?

Base64 is a binary-to-text encoding scheme that represents binary data in ASCII string format. It's commonly used to:

  • Embed images in HTML/CSS/emails
  • Send binary data in JSON payloads
  • Transfer data in URLs safely
  • Store binary data in databases

Browser Implementation

Modern browsers provide built-in methods for Base64 encoding/decoding:

// Encoding
const text = 'Hello, World!';
const encoded = btoa(text);  // SGVsbG8sIFdvcmxkIQ==

// Decoding
const decoded = atob('SGVsbG8sIFdvcmxkIQ==');  // Hello, World!

// For Unicode strings
const encodedUnicode = btoa(unescape(encodeURIComponent(text)));

Data URI Scheme

Base64 is commonly used in Data URIs for embedding images in HTML/CSS:


<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..." />

/* Image as Base64 in CSS */
.logo {
    background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...);
}

Important Notes

When working with Base64:

  • Base64 encoded data is ~33% larger than the original
  • Not suitable for large files in HTML (increases page load time)
  • Use for small images/icons or when direct binary transfer isn't possible
  • Always validate decoded data before using it in your application