Beautify JSON in Vim


Given the file is opened in your editor:

$ vim example.json

You can use python:

:%!python -m json.tool

Or jq:

:%!jq '.'

And for completeness, there’s a site for beautifying JSON too.