You can use direct access to this page from your browser address bar.
Type the string that you need to encode or decode according to the following schema:
https://md5calc.com/html/<TYPE:enc|dec>/<PHRASE>
For example, to visit a page that contains encoded "<strong>", you can just visit the URL:
https://md5calc.com/html/enc/<strong>
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/html/<TYPE:enc|dec>.<OUTPUT:plain|json>/<PHRASE>
Example:
https://md5calc.com/html/enc.plain/<strong>
Will output:
<strong>
We have removed the CORS restriction so you can use direct access to htmlspecialchars encode/decode in your JavaScript applications via AJAX.
Example:
var toEncode = '<strong>';
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
console.log('String "'+toEncode+'"'
+' encoded with htmlspecialchars is'
+' "'+JSON.parse(xhr.response)+'"'
);
};
};
xhr.open('GET', 'https://md5calc.com/html/enc.json/'+encodeURIComponent(toEncode), true);
xhr.send();
Will output:
String "<strong>" encoded with htmlspecialchars is "<strong>"
You can use direct access to this function in your applications.
PHP Example:
<?php
$str = '<strong>';
$url ='http://md5calc.sv/html/enc.plain/'.urlencode($str);
$htmlencoded = file_get_contents($url);
echo 'String "'.htmlspecialchars($str, ENT_QUOTES|ENT_IGNORE)
.'" encoded with htmlspecialchars is "'
.htmlspecialchars($htmlencoded, ENT_QUOTES|ENT_IGNORE).'"'
;
Will output:
String "<strong>" encoded with htmlspecialchars is "<strong>"
Keep in mind that this example makes no sense because PHP has built-in functions htmlspecialchars() and htmlspecialchars_decode(), which do the same.
<?php
$str = '<script>';
$htmlSpecialCharsEncodedStr = htmlspecialchars($str, ENT_QUOTES | ENT_IGNORE);
$htmlSpecialCharsDecodedStr = htmlspecialchars_decode($htmlSpecialCharsEncodedStr, ENT_QUOTES);
echo '<pre>';
echo htmlspecialchars($str, ENT_QUOTES|ENT_IGNORE).PHP_EOL
.' → '.htmlspecialchars($htmlSpecialCharsEncodedStr, ENT_QUOTES|ENT_IGNORE).PHP_EOL
.' → '.htmlspecialchars($htmlSpecialCharsDecodedStr, ENT_QUOTES|ENT_IGNORE).PHP_EOL
;
echo '</pre>';