Formatters

Pretty print XML

XML Formatter re-indents the XML you paste, turning single-line feeds, sitemaps and API responses into readable trees. It first checks that the XML is well-formed (matching tags, quoted attributes, escaped ampersands, one root element) and reports the line and column of the first problem instead of formatting a broken document. Short elements such as <name>toolbox101</name> stay on one line, and "Indent" offers 2 spaces, 4 spaces (the default) or a tab. Developers use it to inspect RSS, sitemaps and SOAP payloads.

How to use XML Formatter

  1. Open XML Formatter in the Toolbox101 app.
  2. Paste the XML you want to read into the XML box; a minified feed, sitemap or API body works well.
  3. Pick Indent: 2 spaces, 4 spaces (the default) or Tab.
  4. Read the nested version in the Output box. If the XML is malformed, the box names the line and column instead.
  5. Click Copy to put the formatted XML on your clipboard.

Worked example

XML Formatter returns the output below for this input.

Input

<config><name>toolbox101</name><features><feature id="format">true</feature><feature id="minify">true</feature></features></config>

Output

<config>
    <name>toolbox101</name>
    <features>
        <feature id="format">true</feature>
        <feature id="minify">true</feature>
    </features>
</config>

Check it yourself: open XML Formatter and enter the same input.

Frequently asked questions

Does this XML formatter validate my XML?

It checks well-formedness: matching and closed tags, quoted attribute values, no duplicate attributes, escaped & and <, comments without -- and a single root element. A problem is reported with its line and column. It does not validate against a schema or DTD, so use xmllint or an IDE for that.

How do I change the indent size?

Use the Indent list above the input: 2 spaces, 4 spaces (the default) or a tab. The output updates as soon as you change it.

Can it format XML with attributes and namespaces?

Yes. Attributes, namespace prefixes, comments, CDATA and processing instructions pass through exactly as written; the worked example carries an id attribute and it survives untouched. Only the whitespace between tags is rewritten.

What is the difference between the XML and HTML formatters?

The XML formatter lays out XML tag by tag with its own well-formedness check, and never adds or drops a tag. The HTML formatter is built for HTML: it knows void tags such as <br>, inline elements and optional end tags, none of which are legal XML. Use this page for XML documents, feeds and sitemaps, and the HTML Formatter for HTML.

Use XML Formatter now

Runs in your browser. Nothing you type is uploaded.