Base64 Encode / Decode

Encode text to Base64 or decode Base64 strings back to plain text.

How to Use the Base64 Tool

Type or paste your text into the input field, then click "Encode to Base64" to convert it. To decode, paste a Base64 string and click "Decode from Base64." Use the "Swap" button to move the output back into the input for further operations, and "Copy Output" to copy the result.

What Is Base64?

Base64 is a group of binary-to-text encoding schemes that represent binary data using a set of 64 ASCII characters. The standard Base64 alphabet consists of uppercase letters (A-Z), lowercase letters (a-z), digits (0-9), plus (+), and forward slash (/). The equals sign (=) is used for padding.

The encoding process takes groups of 3 bytes (24 bits) from the input and divides them into four 6-bit groups. Each 6-bit group maps to one of the 64 characters in the alphabet, producing 4 output characters for every 3 input bytes.

Common Uses for Base64

Data URIs in Web Development

Base64 allows embedding images, fonts, and other binary files directly in HTML and CSS using data URIs. This eliminates extra HTTP requests and can improve page load performance for small files. For example, a small icon can be embedded as a Base64 data URI in a CSS background-image property.

Email Attachments (MIME)

Email protocols (SMTP) were originally designed for plain text. MIME (Multipurpose Internet Mail Extensions) uses Base64 to encode binary attachments like images and documents so they can be safely transmitted through email systems.

API Data Transmission

When APIs need to transmit binary data within JSON or XML payloads, Base64 encoding ensures the data remains intact. This is common for image uploads, file transfers, and cryptographic signatures.

Authentication

HTTP Basic Authentication encodes the username and password in Base64 format. While this is not encryption, it packages the credentials in a format suitable for HTTP headers.

Base64 vs. Other Encoding Schemes

  • Base64 vs. URL Encoding: URL encoding replaces unsafe characters with percent-encoded equivalents. Base64 encodes entire binary data into text. They serve different purposes.
  • Base64 vs. Hex: Hexadecimal encoding represents each byte as two hex characters, resulting in a 100% size increase. Base64 is more efficient at approximately 33%.
  • Base64URL: A URL-safe variant that replaces + with - and / with _, avoiding issues in URLs and filenames.

Tips for Working with Base64

  • Base64 is not encryption — never use it to protect sensitive data.
  • For web images, only use Base64 data URIs for small files (under 10KB). Larger images are better served as separate files.
  • If your Base64 string does not decode properly, check for extra whitespace or line breaks that may have been introduced during copying.
  • Use Base64URL encoding when the output will be used in URLs or filenames to avoid character conflicts.

Frequently Asked Questions

What is Base64 encoding?
Base64 is a binary-to-text encoding scheme that converts binary data into an ASCII string using 64 printable characters (A-Z, a-z, 0-9, +, /). It is commonly used to transmit binary data over text-based protocols like email and HTTP.
Why is Base64 used?
Base64 ensures data integrity when transmitting binary content through systems that only support text. Common uses include embedding images in HTML/CSS, encoding email attachments (MIME), and transmitting data in JSON or XML payloads.
Does Base64 encrypt data?
No. Base64 is an encoding scheme, not an encryption method. It does not provide any security. Anyone can decode a Base64 string back to its original content. For security, use encryption algorithms like AES or RSA.
Why does Base64 make data larger?
Base64 encodes 3 bytes of binary data into 4 ASCII characters, resulting in approximately 33% size increase. This overhead is the trade-off for ensuring compatibility with text-only transmission channels.
Is my data safe?
Yes. All encoding and decoding happens locally in your browser. No data is sent to any server. Your input remains completely private.

Related Tools