Base64 Encode and Decode Tool

Input: Encode Decode

Output:

What is Base64

Base64 is a binary-to-text encoding scheme that converts binary data into a text format using a set of 64 printable characters.

Find more information about Base64 encoding and decoding on Wikipedia

Base64 Programming Examples

Javascript

Encoding and decoding Base64 data can be done with the btoa() and atob() functions in Javascript.

// encode to base64
var encoded_text = btoa('some example text'); 
alert(encoded_text); // alerts "c29tZSBleGFtcGxlIHRleHQ="

// decode base64 
var decoded_text = atob('c29tZSBleGFtcGxlIHRleHQ=');
alert(decoded_text); // alerts "some example text"
			

PHP

Encoding and decoding Base64 data can be done with the base64_encode() and base64_decode() functions in PHP.

// encode to base64
$encoded_text = base64_encode('some example text'); 
echo $encoded_text; // echos "ZXhhbXBsZSB0ZXh0"

// decode base64 
$decoded_text = base64_decode('ZXhhbXBsZSB0ZXh0');
echo $decoded_text; // echos "some example text"