# Quickly Format and Indent JSON Files in a vim Buffer

Skip the online JSON formatters! Run this directly in the vim command line and your minified JSON will be indented and readable, in your current buffer.

Skip the online JSON formatters! Run this directly in the vim command line:

:!python -m json.tool


To make it even easier, I set up a shortcut in my vimrc which will run the above command but also set the filetype to json.
nnoremap ,j :set ft=json<cr>:%!python -m json.tool<cr>gg=G<cr>

Note my map leader is , (comma), so ,j (for JSON) will call the function on my current buffer.