Base64 FAQ

Usage from Address Bar

Access this page directly from your browser's address bar. Enter the string you want to encode/decode using the following schema: https://md5calc.com/base64/<TYPE:enc|dec>/<PHRASE> For example, to visit the page with the encoded string "hello world", simply go to: https://md5calc.com/base64/enc/hello+world Another cool feature is that you can specify "json" or "plain" mode in the URL to get only the encoded/decoded string in the response.
Schema of this feature: https://md5calc.com/base64/<TYPE:enc|dec>.<OUTPUT:plain|json>/<PHRASE> Example: https://md5calc.com/base64/enc.plain/hello+world Will output: aGVsbG8gd29ybGQ=

Usage from Javascript

We have removed CORS restriction so you can access the base64 encode/decode functionality directly in your JavaScript applications via AJAX.

Example:

var toEncode = 'hello world';
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
    if (xhr.readyState == 4 && xhr.status == 200) {
        console.log('Base64 of "'+toEncode+'" is "'+JSON.parse(xhr.response)+'"');
    };
};
xhr.open('GET', 'https://md5calc.com/base64/enc.json/'+encodeURIComponent(toEncode), true);
xhr.send();
Will output: Base64 of "hello world" is "aGVsbG8gd29ybGQ="

Usage from PHP

You can access this function directly in your applications.

PHP Example:

<?php
    $str = 'hello world';
    $url ='https://md5calc.com/base64/enc.plain/'.urlencode($str);
    $base64 = file_get_contents($url);
    echo 'Base64 of "'.$str.'" is "'.$base64.'"';
Will output: Base64 of "hello world" is "aGVsbG8gd29ybGQ="

How to do the same in PHP

<?php
    $str = '¡Hola!';
    $base64EncodedStr = base64_encode($str);
    $base64DecodedStr = base64_decode($base64EncodedStr);
    echo '
    <pre>';
    echo $str.PHP_EOL
         .' &rarr; '.$base64EncodedStr.PHP_EOL
         .' &rarr; '.$base64DecodedStr.PHP_EOL
    ;
    echo '</pre>';

How to do the same in JavaScript

var str = 'https://localhost/?param1=¡Hola!&param2=¡Hola!';
var base64EncodedStr = btoa(str);
var base64DecodedStr = atob(base64EncodedStr);
console.log(str);
console.log('-> ' + base64EncodedStr);
console.log('-> ' + base64DecodedStr);
Please read the privacy policy (agreement of the cookies usage, other websites embedded content, etc.). If you continue to use the site, we will assume that you agree with our privacy policy.
OkPrivacy Policy