Free Online Base64 Encoder & Decoder

Convert text or data to and from Base64 encoding instantly. Automatically detects whether to encode or decode based on your input.

Related Tools

Frequently Asked Questions

What is Base64 encoding?

Base64 encodes binary or text data into a string using only 64 printable ASCII characters (A–Z, a–z, 0–9, +, /). It is used in email attachments, data URIs, and API tokens where binary data needs to be safely embedded in text-based formats.

Does Base64 encrypt my data?

No. Base64 is encoding, not encryption. The original data can be recovered by anyone with a decoder. Do not use Base64 to hide sensitive information.

What is the size overhead of Base64?

Base64 output is approximately 33% larger than the input. Every 3 bytes of input become 4 characters of output.

Base64 Encoding: What It Is and Why Developers Need It

Base64 encoding is one of those fundamental technologies that most developers encounter early in their careers but rarely stop to fully understand. It appears in email attachments, data URLs in HTML and CSS, authentication headers, and embedded images across virtually every web platform. At its core, Base64 is a way to represent binary data — data that exists as raw bytes — using a set of 64 printable ASCII characters that can safely travel through text-based systems without being corrupted or misinterpreted by intermediary processes.

The Origins of Base64 Encoding

Base64 was developed in response to a fundamental limitation of early internet communication protocols. Systems like SMTP, designed to transfer email, were built to handle 7-bit ASCII text. Binary data — images, audio files, executables — uses all 8 bits of each byte, meaning that the high bit could be stripped, corrupted, or misinterpreted by these text-oriented systems. A standard encoding scheme was needed that could represent arbitrary binary data using only the safe subset of printable ASCII characters, and Base64 emerged as the solution, ultimately standardized in RFC 4648.

The name "Base64" refers to the 64 characters used in the encoding alphabet: uppercase A through Z, lowercase a through z, digits 0 through 9, and the symbols plus (+) and forward slash (/), with the equals sign (=) used as padding. Every 3 bytes of binary input are converted into 4 Base64 characters, which means the encoded output is always approximately 33 percent larger than the original binary. This size overhead is the trade-off for guaranteed safe transmission through any text-based system.

How Base64 Works

The encoding process works by taking 3 bytes of binary data — 24 bits total — and dividing them into four groups of 6 bits each. Each 6-bit group represents a number from 0 to 63, which maps to one character in the Base64 alphabet. If the input data is not a multiple of 3 bytes, padding characters (=) are added to the output to maintain the 4-character group structure. Decoding simply reverses this process: each Base64 character is converted back to its 6-bit value, the groups are reassembled, and the original bytes are recovered.

URL-safe Base64 is a variant that replaces the + and / characters with - and _ respectively, making the encoded output safe to include directly in URLs without percent-encoding. This variant is commonly used in JWT tokens, OAuth flows, and other web authentication protocols where Base64-encoded data needs to appear in query strings or URL path segments without breaking URL parsing. When working with web APIs, it is important to know which variant — standard or URL-safe — the system expects, as mixing them causes decoding failures.

Common Use Cases for Base64

One of the most visible uses of Base64 in web development is embedding images directly into HTML or CSS as data URLs. Instead of referencing an external image file with a URL, you can encode the image bytes as Base64 and embed them inline: src="data:image/png;base64,iVBORw0KGgo...". This technique eliminates an HTTP request, which can improve performance for small images like icons or logos. It is also commonly used in email templates where images might not be accessible from an external server.

Base64 also appears frequently in API authentication. The HTTP Basic Authentication scheme encodes credentials as Base64: the username and password are joined with a colon, encoded to Base64, and sent in the Authorization header. While this provides no encryption — Base64 is encoding, not encryption — it ensures the credential string contains only safe ASCII characters compatible with the header format. JSON Web Tokens use Base64url encoding for both the header and payload sections, making the token self-contained and safe for URL transport.

Base64 in Security and Authentication

Understanding Base64 is critical for anyone working with web security. Many developers mistakenly believe that Base64-encoded data is encrypted or obfuscated, when in reality it is trivially reversible by anyone with access to the encoded string. A Base64-encoded password or API key offers zero security protection on its own. In HTTP Basic Auth, the credentials are essentially sent in plaintext — which is why this scheme must always be used over HTTPS, never plain HTTP. The Base64 encoding satisfies the format requirements of the Authorization header; the encryption is provided by TLS.

When you encounter a Base64 string in a security context — a JWT token, a cookie value, an API response — decoding it can reveal valuable debugging information. The payload of a JWT, for example, contains claims about the user's identity, roles, and session expiry in plain JSON. Decoding and inspecting this data helps diagnose authentication issues without needing access to the server. However, remember that the decoded data should never be trusted as authoritative without verifying the token's cryptographic signature — reading is safe, trusting unsigned data is not.

Limitations and Misconceptions

The 33 percent size overhead of Base64 encoding has practical implications when deciding whether to embed resources as Base64 data URLs. For small images — icons below 2 KB — the overhead is negligible and the elimination of an HTTP round trip is beneficial. For larger images, the increased data size outweighs the saved request, and external image references with proper caching headers are more efficient. The same logic applies to any binary data: Base64 is excellent for small payloads where text safety matters, but inefficient for large binary transfers where direct binary protocols or multipart encoding are superior choices.

Another common misconception is that Base64 is universally interchangeable across systems. Different platforms may use different line wrapping lengths, different alphabet variants, or different padding rules, leading to decoding failures when data moves between systems. Always verify which variant a system expects and test with sample data before building a production integration. When building your own encoding, explicitly choose the variant — standard or URL-safe — and document it clearly for consumers of your API or data format. These small details prevent subtle, hard-to-diagnose compatibility bugs in production.