Skip to Content

Vim - Pretty JSON

Posted on

Pretty JSON

Whenever I encounter messy JSON formatting, I typically use JSON Pretty Print to reformat the JSON. However, this approach can be insecure when dealing with sensitive data.

Today, I discovered a way to prettify JSON using only Vim with the following command:

:%!python -m json.tool

You can map this command to a keystroke for quicker access. Additionally, if you have the jq tool installed, you can use the command :%!jq . instead.

comments powered by Disqus