Pretty-print XML or jSon via the Terminal in OS X

Simply copy the jSon or XML into your clipboard and then run one of the following:

pbpaste | python -m json.tool > formatted.json

For XML:

pbpaste | xmllint --format - > formatted.xml

Leave a Reply

Your email address will not be published. Required fields are marked *