How to autoformat JSON in vim

Enter visual mode, highlight a valid JSON snippet, and then pipe it to the JSON module in Python:

:'<,'>!python -m json.tool

Your snippet will either be formatted or be replaced by an error message indicating where the JSON syntax went awry.