Free XML formatter (indent) tool on Mac? [closed] Free XML formatter (indent) tool on Mac? [closed] xml xml

Free XML formatter (indent) tool on Mac? [closed]


I use TextWrangler (free) together with a text filter which uses xmllint. Download it here: http://www.barebones.com/products/textwrangler/download.html

After you have it, create a new file and save it with a name like tidy.sh under ~/Library/Application Support/TextWrangler/Text Filters. Write the following in the file and save it:

#!/bin/shXMLLINT_INDENT=$'\t' xmllint --format --encode utf-8 - 

The above should also work for BBEdit 11. For versions of TextWrangler < 4.0 or BBEdit < 11, this script should be slightly different:

#!/bin/shxmllint "$*" | XMLLINT_INDENT=$'\t' xmllint --format --encode utf-8 -

Then you'll be able to apply this from the Text menu > Apply Text Filter > tidyTo make it even easier, you can bind a shortcut to this.Go to Window > Palettes > Text Filters. You will see your tidy filter there. Select and hit "Set Key..." and choose a combination that suits you (I use alt+cmd+x).


I suggest you install XMLLint which the best solution to view pretty formatted XML (included in LibXML package.