VIM allows execute external commands and replace neccessary line/block with the command output.
:.- current line:%- full buffer:1,10- line range:'<,'>- visually selected block
Format JSON with jq
:.!jq .
XML:
:%!xmllint --format -
Example, parse and sort terraform JSON output:
:%s,\\",",g
:%!jq '.[].environment = ( .[].environment | sort_by(.name) )'