Back to TIL
shell

Commandline JSON Pretty Print everywhere

You can pretty-print (and validate) JSON on nearly every *nix-like (Unix, Linux, macOS…) system, since most of them include Python (≥2.6) by default:

echo '{"test1": 1, "test2": "win"}' | python -m json.tool

Which outputs:

{
    "test1": 1,
    "test2": "win"
}

And if you’re editing a JSON file in Vim, run:

:%!python -m json.tool