Text Beautifier

Text Beautifier


About the XML Beautifier

XML is still everywhere in enterprise software: SOAP web services, RSS and Atom feeds, Maven pom.xml files, .NET .csproj and web.config files, Android layouts, SVG images and countless data-exchange formats between banks, insurers and government systems. When XML is generated by a program it often arrives as one unbroken line, which makes it hard to see which element belongs to which parent.

The XML beautifier parses your document, checks that it is well-formed, and re-indents every element so the hierarchy is visible. Attributes, namespaces, comments and CDATA sections are preserved; only the whitespace between elements changes.

Common uses

  • Inspecting SOAP requests and responses captured from a service or proxy log.
  • Reviewing generated configuration files and project files before committing.
  • Reading RSS/Atom feeds, sitemaps or SVG markup.
  • Finding the element that is missing a closing tag in a broken document.

How to use it

  1. Paste the XML into the input box (or click Try Me for a sample).
  2. Press Beautify to get an indented, highlighted version.
  3. Copy or save the result. If the document is not well-formed, the error message gives the line and position of the problem.

Example

A compact order document is expanded into a readable tree:

Input
<order id="1001"><customer>Alice</customer><items><item sku="A1" qty="2"/><item sku="B7" qty="1"/></items></order>
Output
<order id="1001">
  <customer>Alice</customer>
  <items>
    <item sku="A1" qty="2" />
    <item sku="B7" qty="1" />
  </items>
</order>

Tips and common pitfalls

  • Well-formed means every tag is closed, tags are properly nested, attribute values are quoted and there is exactly one root element. It does not mean the document matches a schema (XSD).
  • Special characters in text must be escaped: &lt; for < and &amp; for &. The Escape / Unescape tool can do this for you.
  • Whitespace inside text nodes can be significant in some formats (for example in xml:space="preserve" elements), so check the result if exact spacing matters.
  • Element and attribute names are case-sensitive: <Item> and <item> are different elements.

Frequently asked questions

Does the beautifier validate against an XSD schema?

No. It checks that the XML is well-formed (correct syntax), which is enough to format it. Schema validation checks business rules such as required elements and data types and needs the schema file.

Will formatting change the meaning of my XML?

In almost all cases no — only the whitespace between elements changes. Formats that treat whitespace inside mixed content as significant are the exception.

Can I format XML with namespaces and prefixes?

Yes. Namespace declarations and prefixed element names such as soap:Envelope are kept exactly as written.

What is the difference between XML and HTML?

Both use tags, but XML is strict (every tag must be closed, names are case-sensitive) and lets you define your own elements, whereas HTML has a fixed vocabulary and browsers tolerate many errors. Use the HTML Beautifier for web pages.

Related