URL Encode/Decode FAQ

Usage from Address Bar

You can use direct access to this page from your browser address bar. Type the string you need to encode or decode according to the following schema: https://md5calc.com/url/<TYPE:enc|dec>/<PHRASE> For example to visit page that contains encoded "¡Hola!" you can just visit url: https://md5calc.com/url/enc/¡Hola! Another cool feature is that you can specify "json" or "plain" mode in the URL and you will get only the encoded/decoded string in response.
Schema for this feature: https://md5calc.com/url/<TYPE:enc|dec>.<OUTPUT:plain|json>/<PHRASE> Example: https://md5calc.com/url/enc.plain/¡Hola! Will output: %C2%A1Hola%21

Usage from JavaScript

We have removed the CORS restriction so you can use direct access to URL encode/decode in your JavaScript applications via AJAX.

Example:

var toEncode = '¡Hola!';
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
  if (xhr.readyState == 4 && xhr.status == 200) {
    console.log('Urlencoded "'+toEncode+'" is "'+JSON.parse(xhr.response)+'"');
  };
};
xhr.open('GET', 'https://md5calc.com/url/enc.json/'+encodeURIComponent(toEncode), true);
xhr.send();
Will output: Urlencoded "¡Hola!" is "%C2%A1Hola%21"

Usage from PHP

You can use direct access to this function in your applications.

PHP Example:

<?php
    $str = '¡Hola!';
    $url ='https://md5calc.com/url/enc.plain/'.urlencode($str);
    $urlencoded = file_get_contents($url);
    echo 'Urlencoded "'.$str.'" is "'.$urlencoded.'"';
Will output: Urlencoded "¡Hola!" is "%C2%A1Hola%21"

How to do the same in PHP

<?php
    $str = '¡Hola!';
    $urlencodedStr = urlencode($str);
    $urldecodedStr = urldecode($urlencodedStr);
    echo '<pre>';
    echo $str.PHP_EOL
         .' &rarr; '.$urlencodedStr.PHP_EOL
         .' &rarr; '.$urldecodedStr.PHP_EOL
       ;
    echo '</pre>';

How to do the same in JavaScript

If you need to encode the whole URL

var str = 'https://localhost/?param1=¡Hola!&param2=¡Hola!';
var urlencodedStr = encodeURI(str);
var urldecodedStr = decodeURI(urlencodedStr);
console.log(str);
console.log('-> ' + urlencodedStr);
console.log('-> ' + urldecodedStr);

If you need to encode a value only

var url = 'https://localhost/';
var str = '¡Hola!';
var urlencodedStr = encodeURIComponent(str);
var urldecodedStr = decodeURIComponent(urlencodedStr);
console.log(str);
console.log('-> https://localhost/?param1=' + urlencodedStr);
console.log('-> https://localhost/?param1=' + urldecodedStr);
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