In Vim, use command below to format text as json in current buffer.
:%!python -m json.tool
Source: https://blog.realnitro.be/2010/12/20/format-json-in-vim-using-pythons-jsontool-module/
Alternative approach using jq
:
:%! jq '.'
Source: https://dev.to/gypsydave5/the-unix-way-or-why-you-actually-want-to-use-vim-3n8p