Base64 Encode and Decode: The Complete Guide to Base64 Encoding

Learn what Base64 encoding is, how it works, and when to use it. Encode and decode Base64 data for emails, APIs, data URIs, and more.

February 13, 2026

What Is Base64 Encoding?

Base64 is a binary-to-text encoding scheme that converts binary data into a string of ASCII characters. It uses a set of 64 characters: the uppercase letters A-Z, lowercase letters a-z, digits 0-9, and two special characters (typically + and /). The name Base64 directly reflects this 64-character alphabet. Our Base64 Encode and Decode tool lets you convert data in either direction instantly.

How Does Base64 Work?

Base64 encoding works by taking every three bytes (24 bits) of binary data and splitting them into four groups of 6 bits each. Each 6-bit group maps to one of the 64 characters in the Base64 alphabet. If the input data is not a multiple of three bytes, padding characters (=) are added to the output to maintain alignment.

For example, the text Hello in Base64 becomes SGVsbG8=. The process is entirely reversible: decoding SGVsbG8= returns the original Hello. This lossless round-trip capability is what makes Base64 so useful for data transport.

Why Use Base64 Encoding?

Base64 exists to solve a fundamental problem: many communication protocols and storage systems are designed to handle text, not raw binary data. Base64 bridges this gap by encoding binary data into a text-safe format. Here are the most common use cases:

Email Attachments (MIME)

Email was originally designed to transmit ASCII text only. Base64 encoding allows binary files like images, PDFs, and documents to be embedded in email messages via the MIME (Multipurpose Internet Mail Extensions) standard. Your email client automatically encodes attachments to Base64 when sending and decodes them when receiving.

Data URIs

Data URIs allow you to embed small files directly in HTML or CSS using the format data:image/png;base64,iVBORw0KGgo.... This eliminates extra HTTP requests for small assets like icons or thumbnails, which can improve page load performance.

API Payloads

When APIs need to transmit binary data (images, files, certificates) within JSON payloads, Base64 encoding is the standard approach. Since JSON only supports text values, binary data must be encoded to Base64 before inclusion.

Authentication Headers

HTTP Basic Authentication encodes the username and password combination in Base64 before transmitting it in the Authorization header. While this is not encryption, it ensures the credentials are transmitted in a text-safe format.

Storing Binary Data in Text Formats

Databases, configuration files, and XML documents that only support text can store binary data by encoding it to Base64. This is common for storing encryption keys, certificates, and small binary blobs.

Base64 Is Not Encryption

A critical distinction: Base64 is not encryption. It provides no security whatsoever. Anyone can decode a Base64 string back to its original data without any key or password. Base64 is purely a data encoding scheme designed for safe transport, not confidentiality. If you need to protect data, use proper encryption algorithms like AES or RSA before optionally encoding the ciphertext to Base64 for transport.

Base64 Variants

There are several Base64 variants for different contexts:

  • Standard Base64: Uses A-Z, a-z, 0-9, +, / with = padding. Defined in RFC 4648.
  • URL-Safe Base64: Replaces + with - and / with _ to avoid URL encoding conflicts. Used in JWTs and URL parameters.
  • MIME Base64: Adds line breaks every 76 characters for email compatibility.

How to Use the Base64 Tool

Paste any text into the input field to encode it to Base64, or paste a Base64 string to decode it back to plain text. The tool handles standard and URL-safe variants, validates input format, and provides instant results. It runs entirely in your browser with no data transmitted to any server, ensuring complete privacy.

Size Considerations

Base64 encoding increases data size by approximately 33%. Three bytes of input become four characters of Base64 output. Keep this overhead in mind when encoding large files, as it impacts bandwidth and storage requirements.