Skip to content

Instantly share code, notes, and snippets.

@cobodo
Last active December 15, 2015 13:39
Show Gist options
  • Save cobodo/5268859 to your computer and use it in GitHub Desktop.
Save cobodo/5268859 to your computer and use it in GitHub Desktop.
bookmarklet to make JSON human readable
javascript:(function(d,n,t,k,i,s){s=[[/\\(["\\/])/g,"$1"],[/\\b/g,"\b"],[/\\n/g,n],[/\\u([a-fA-F0-9]{4})/g,function(_,u){return String.fromCharCode(parseInt(u,16));}],[/([{\[,])/g,"$1\n"],[/([}\]])/g,"\n$1"]].reduce(function(p,o){return p.replace(o[0],o[1]);},d.body.innerHTML).split(n);for(;i<s.length;++i){if(s[i].search(/}|\]/)!=-1)k=k.substr(4);s[i]=k+s[i];if(s[i].search(/{|\[/)!=-1)k+=t;}d.body.innerHTML='<pre>'+s.join(n)+'</pre>';})(document,"\n"," ","",0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment