Base64 Encode/Decode

Convert text to Base64 or decode Base64 to text with this free online tool. You can also encode and decode files such as images, documents, and more.

Text to Encode

Enter text or upload a file to convert to Base64 format

Base64 Output

Your text converted to Base64 format

Understanding Base64 Encoding

What is Base64?

Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It converts every 3 bytes of binary data into 4 ASCII characters, using a set of 64 characters (A-Z, a-z, 0-9, + and /).

Common Uses

  • Embedding binary data (images, documents) in HTML, XML, or JSON
  • Encoding email attachments (MIME)
  • Storing complex data in cookies or localStorage
  • Data URIs in web browsers
  • API authentication (Basic Auth)

Advantages

  • Safe transfer of binary data through text-only systems
  • Compatible with nearly all protocols and data formats
  • Prevents data corruption during transmission
  • Universal encoding supported across all platforms

How It Works

The encoding process divides binary data into 6-bit segments, each representing a value from 0 to 63. Each value is mapped to a specific character in the Base64 character set. Padding characters (=) may be added at the end to ensure the length is a multiple of 4.

Limitations

  • Increases data size by approximately 33%
  • Not a form of encryption or compression
  • May become unwieldy for very large files
  • Can be slow for large data processing

Base64 in Web Development

<!-- Data URI for an image --> <img src="data:image/png;base64,iVBORw0KGgoAAAAN..." /> <!-- CSS with Base64 background --> .icon { background: url(data:image/svg+xml;base64,PHN2ZyB...) }

Tips for Working with Base64

Size Consideration

Base64 encoding increases file size by ~33%. For large files, consider alternative methods or compression before encoding.

URL-Safe Base64

For URLs, use URL-safe variants where '+' becomes '-' and '/' becomes '_' to avoid encoding issues.

Character Encoding

When encoding non-ASCII text, ensure proper character encoding (like UTF-8) before Base64 encoding.

Frequently Asked Questions

Common questions about Base64 encoding and decoding.

Related Text Tools