← All Articles

Base64 Encoding Explained: What It Is and When to Use It

🔤

If you have ever looked at an email source, an HTTP header, or a data URI for an image, you have seen Base64 encoding — long strings of letters, numbers, and symbols. But what is it actually doing?

What Is Base64?

Base64 is a way to encode binary data (like images, files, or arbitrary bytes) into plain ASCII text. It represents binary data using 64 printable characters: A–Z, a–z, 0–9, plus + and /.

The "64" in the name refers to the 64 characters used (6 bits per character). Every 3 bytes of input becomes 4 Base64 characters — making encoded data about 33% larger than the original.

Why Is Base64 Used?

Base64 exists because many older protocols and systems were designed to handle text only, not arbitrary binary data. Examples:

  • Email attachments: MIME encoding uses Base64 to send binary files through text-based email protocols
  • Data URIs: Embed images directly into HTML/CSS without separate file requests: src="data:image/png;base64,..."
  • JWT tokens: JSON Web Tokens use Base64URL encoding to transmit claims between parties
  • HTTP Basic Auth: Credentials are Base64 encoded in the Authorization header
  • API payloads: Sending binary files through JSON APIs that only accept strings

Base64 vs Base64URL

Standard Base64 uses + and / which are special characters in URLs. Base64URL replaces + with - and / with _, and omits padding = signs, making it safe to use in URLs and filenames without encoding.

Is Base64 Encryption?

No. Base64 is encoding, not encryption. It provides zero security — anyone can decode it instantly. Never use it to "hide" sensitive data.

How to Encode/Decode Online

Use our free Base64 Encoder/Decoder to instantly encode text, URLs, or images to Base64 and decode Base64 strings back to readable text.

← Previous
CSS Minification: How to Reduce Stylesheet Size by 40% Instantly