Today I Learned

A Hashrocket project

Format JSON in Vim with jq

I’ve been using jq to format my JSON. It’s a little less heavy-handed than the more standard Python JSON library; for instance it doesn’t alphabetize my keys or convert my two spaces to four.

Here’s how to use this library inside Vim (command mode):

:%!jq '.'

Happy JSON-ing!

Every developer at Hashrocket is a Vim expert. Check out our development environment, Dotmatrix, and if you are in Chicago, come to the Vim Chicago Meetup hosted at our Chicago office.