Yesterday Holsee introduced me to a new command line tool jq. Prior to this I formatted json given to me in a variety of ways. Sometimes using python, another time I would use a web formatter and I have even been known, on ocassion to go into a REPL. There was never a defacto way of formatting JSON for me... Until now...

It has only been a way a few hours since using it but already I know it will stay with me for a good while. So much so that I already elvated into my workflow in vim.

map ,j :%!jq '.'


What this simply means that I highlight the json I want formatted and type in

,j
and its nicely formatted. As stated before in my workflow I like to stay inside the browser.

Here is an example of a script with some unformattted json.

Simply selected the line with

shift + v
and then hit
,j
and...

On the command line it can be very useful... I am looking forward to using this more and more in the coming months!