4 ms·
> Pretty-print JSON: > echo '{"foo": "bar", "baz": [1, 2, 3]}' | python -m json.tool This is even more fun on MacOS if you combine it with the pbpaste/pbcopy u
by 9dev 3y ago
> Pretty-print JSON:
> echo '{"foo": "bar", "baz": [1, 2, 3]}' | python -m json.tool
This is even more fun on MacOS if you combine it with the pbpaste/pbcopy utils:
alias json_pretty="pbpaste | python -m json.tool | pbcopy"
That command will pretty-print any JSON in your clipboard, and write it back to the clipboard, so you can paste it somewhere else formatted!
- TRiG_Ireland 3y agoalias json-format="python -m json.tool | pygmentize -l javascript"
- scruple 3y agoI have a similar mapping to use `json.tool` inside of vim buffers. Very useful tool that's gotten a ton of mileage from me over the last ~decade.