How to Format JSON in Vim

John John (304)
5 minutes

Vim is amazing. Well, Python is doing all the work, but I still like Vim. Learn how to format JSON in Vim like a pro with this short guide!


Paste your json, and run this in vim normal mode.

:%!python -m json.tool
Posted in these interests:
h/vim23 guides
h/python67 guides
Paste your ugly JSON in Vim

Enter visual mode using 'v' and paste the ugly JSON.

Use Python to format the JSON

In normal mode type:

:%!python -m json.tool


AKA the Walrus Operator
John John (304)

Many languages support assignment expressions, and with version 3.8 (PEP 572), Python is joining the party.