Base64 Encoder and Decoder

Convert Base64 in your browser using Javascript.

There are other base64 conversion tools out there, but they send your data to the server. If you are working with any sensitive information, you will want to use a more secure tool like this one. Your data is never sent to the server so we can't see what you type.

This tool supports both encoding and decoding base64 strings. To Encode, put your plaintext in the first textarea and click "Encode." To Decode, put your base64 string in the second textarea and click "Decode."

What is Base-64 Encoding?

Base-64 is a common encoding format used to represent a binary string as characters. Base-64 strings contain characters 0-9 and A-z. This format is convenient for sending binary data over the wire. Because the base ASCII characters are widely supported, you can be reasonable certain that your base-64 encoded string will reach its destination as intended.

Base-64 can also be use to obfuscate strings to make them harder to read. But base-64 is not encryption and should not be used to security purposes.

Why Base-64 String end with Equal Sign

You can identify a base-64 string by its tell-tail format. Base-64 strings typically end in a single or double equal sign ("=" or "==").

First, base-64 strings do not always end in an equal sign. The equal signs are used as padding. Base-64 encodes data in 3-byte chunks which are encoded as 4-bytes. This means that 3 characters of input become 4 characters of output. If the input does not contain a number of bytes that is dividable by 3, the output will be padded with "=" or "==".

How Encode/Decode Base-64 with Javascript?

Using Javascript to base-64 encode or decode a string is pretty easy. The example below shows how to encode and decode a string using Javascript.

function encode(str){
  return window.btoa(str);
function decode(str){
  return window.atob(str);
var input   = "Hello Alan!",
    encoded = encode(input),
    decoded = decode(encoded);

console.log(encoded); // SGVsbG8gQWxhbiE=
console.log(decoded); // Hello Alan!