Reformat JSON reponse in Chrome Browser Bookmarklet

If you call a RESTful web service using the Google Chrome browser (rather than using Microsoft Internet Explorer) it will display the JSON response directly in the browser window. However, the JSON will look like one continuous jammed together string of characters by default. To format the JSON nicely within the Chrome browser window, we can add a handy bookmarklet which will use JavaScript to reformat the JSON with appropriate carriage returns and white space tabs.

Hope you find this handy.

-- Todd

Source (google.com)


Download Bookmarklet:


View Bookmarklet Code:

Bookmarklet Source Code:

javascript%3Avar%20json%3DJSON.parse%28document.getElementsByTagName%28%22pre%22%29%5B0%5D.innerHTML%29%3Bdocument.write%28%22%3Cpre%3E%22+JSON.stringify%28json%2Cnull%2C4%29+%22%3Cpre%3E%22%29%3B


Rate it:


Tags:

Comments

Comments so far. Add yours.