Pretty Printing XML

Comments

tidy is a command line tool to pretty print XML.

What is tidy?

It’s a very unslick util for tidying up HTML markup which gets the job done. It also has an XML mode, which is what is useful here. To install it on OS X, simply do

1
> brew install tidy

Tidy usage

To pretty print input.xml and save the output to pretty_printed.xml

1
> tidy -xml -i input.xml > pretty_printed.xml

There are several command line options. For example, to change the case of tabs to uppercase:

1
> tidy -xml --uppercase-tags y  -i input.xml

Comments