Base64 (MIME) Encode and Decode Tool

Use this free tool to turn binary data into text (encode) or text into binary (decode). To allow binary data to be transmitted with textual data it must be encoded. An example of this is an attachment in an email. This is done via the MIME implementation of Base64. The MIME implementation uses the characters A-Z, a-z, and 0-9 for the initial 62 values that it can use to encode data.

For example, the text:

Dan's Tools are cool!

Would be encoded as...


What is Base64 encoding?

The term Base 64 is generic, and there are many implementations. MIME, which stands for Multi-Purpose Internet Mail Extensions, is the most common that is seen today. It is used to transmit attachments via email over the Simple Mail Transfer Protocol (SMTP). Other examples of Base64 encoding are Radix-64 and YUI's Y64. Encoding data in Base64 results in it taking up roughly 33% more space than the original data.

MIME Base64 encoding is the most common, and is based on the RFC 1420 specification. It also uses a = character at the end of a string to signify whether the last character is a single or double byte.

When and why would you use Base64 encoding?

You should use Base64 whenever you intend to transmit binary data in a textual format.

Code Examples

Perlencode_base64($string);decode_base64($string);Requires use MIME::Base64;
JavaBase64.encodeBase64(string);Base64.decodeBase64(string);Requires import org.apache.commons.codec.binary.Base64;
JavaScriptbtoa(string);atob(string);<= IE9 is unsupported
RubyBase64.encode64('string')Base64.decode64(enc)Requires require "base64"

External Links

  • More information about Base64 (Wikipedia)