JSON FAQ

Usage from Address Bar

You can access this page directly from your browser's address bar. Type the string that you need to encode or decode according to the following schema: https://md5calc.com/json/<TYPE:enc|dec>/<PHRASE> For example, to open a page that contains the JSON-encoded "hello world", you can simply visit this URL: https://md5calc.com/json/enc/hello+world 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 the response.
Schema for this feature: https://md5calc.com/json/<TYPE:enc|dec>.<OUTPUT:plain|json>/<PHRASE> Example: https://md5calc.com/json/enc.plain/hello+world Will output: "hello world"

Usage from JavaScript

We have removed the CORS restriction, so you can directly access JSON encoding/decoding 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('Json encoded "'+toEncode+'" is "'+JSON.parse(xhr.response)+'"');
  };
};
xhr.open('GET', 'https://md5calc.com/json/enc.json/'+encodeURIComponent(toEncode), true);
xhr.send();
Will output: Json encoded "hello world" is ""hello world""

Usage from PHP

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

PHP Example:

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

How to do the same in PHP

<?php
    $str = '¡Hola!';
    $jsonEncodedStr = json_encode($str);
    $jsonDecodedStr = json_decode($jsonEncodedStr, true);
    echo '<pre>';
    echo $str.PHP_EOL
         .' &rarr; '.$jsonEncodedStr.PHP_EOL
         .' &rarr; '.print_r($jsonDecodedStr, true).PHP_EOL
    ;
    echo '</pre>';

How to do the same in JavaScript

var str = 'https://localhost/?param1=¡Hola!&param2=¡Hola!';
var jsonEncodedStr = JSON.stringify(str);
var jsonDecodedStr = JSON.parse(jsonEncodedStr);
console.log(str);
console.log('-> ' + jsonEncodedStr);
console.log('-> ' + jsonDecodedStr);
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