Prettify XML text in BBEdit

When XML data is sent back from a web service, it is in the form of a stream: there are no line breaks or indents to make it easier for humans to read. The example below is typical: the entire XML result is one continuous line. This makes it very hard to troubleshoot your application: you need a utility to put the indents and line-breaks back in.


Screen shot 2011-04-11 at 4.48.48 PM.jpg

Many users of BBEdit may not be aware that it has cleanup functions that will rapidly reformat HTML and XML code into a more legible structure.  Here’s how to get to them:

Select “Tidy” from the Markup menu in BBEdit. Click on Reflow Document.

 2011-06-03_13-51-55.jpg

The default selections are probably OK, but you may want to check off the indenting options for block-level tags and attributes.

Screen shot 2011-04-11 at 4.48.20 PM.jpg

Click Reflow, and you should see something similar to the result shown here. Much easier to read!

Screen shot 2011-04-11 at 4.48.34 PM.jpg