JSON speed

JavaScript performance comparison

Test case created by Aksel Nordal

Preparation code

<span id="uniqueId" data-json='{"first":"abc","second":"def","thrid":"ghi"}'>Yo, here I am world!</span>
Benchmark.prototype.setup = function() {
        function parseJsonX(json) {
                var parsedObj = {};
                json = json.replace(/"|{|}/g,'').split(',');
                for(var l=json.length, i=0;i<l;i++) {
                        var keyValue = json[i].split(':');
                        parsedObj[keyValue[0]] = keyValue[1];
                return parsedObj;
        function parseJsonNative(json) {
                    return JSON.parse(json);
        function parseJsonEval(json) {
                    return eval('(' + json + ')');

Preparation code output

Yo, here I am world!

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
X-browser parsing
var spanEl = document.getElementById('uniqueId');
var obj = parseJsonX(spanEl.getAttribute('data-json'));
JSON parsing
var spanEl = document.getElementById('uniqueId');
var obj = parseJsonNative(spanEl.getAttribute('data-json'));
JSON eval
var spanEl = document.getElementById('uniqueId');
var obj = parseJsonEval(spanEl.getAttribute('data-json'));

Compare results of other browsers


You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:


Comment form temporarily disabled.

Add a comment