JSON formatter bookmarklet

At work I need to read JSON document pretty often and making it pretty will help me pretty much. Last time I showed how to prettify a JSON document using Python script. But since I am working mostly in a browser, having to switch from browser to terminal is a bit cumbersome. There are a lot of online JSON formatter out there but I think it’s too much if I need to make a remote request just to do the formatting. Also the JSON document I need to format can be a sensitive document so it’s also not a good idea to use an online service.

Then I realized browser nowadays has in-browser JSON formatter function: JSON.stringify. I just need to find a way to make using it a bit easier. So I made the following bookmarklet.

Prettify JSON

Drag the link above to bookmark bar in your browser. If you need to format a JSON document, you can click it, then paste the JSON document (make sure it’s valid), and finally click the button there. Voila!