What is the XML Formatter?
The XML Formatter turns a single line of XML, such as a SOAP response, an RSS feed, a sitemap, an Android layout or a config file, into neatly indented text that is easy to read, and checks that it is well-formed while doing so.
Text inside elements is kept exactly as written, so formatting never changes the meaning of mixed content like <p>Hello <b>world</b></p>. Errors such as mismatched tags, missing quotes, duplicate attributes or a bare & are reported with the line, the column and a plain-English explanation.
How to use it
- Paste XML, upload a file, or click Example.
- Choose the indentation, or Minify to remove all formatting.
- Read the formatted XML, or click Show me to jump to an error.
- Copy the result or download it.
Example
<note><to>Asha</to><body>Hi <b>there</b>!</body></note>
<note> <to>Asha</to> <body>Hi <b>there</b>!</body> </note>
Features
- Pretty-print. Indent with 2 or 4 spaces or tabs.
- Minify. Strip indentation and optionally comments for the smallest file.
- Well-formedness check. Mismatched or unclosed tags, unquoted or duplicate attributes, bare & and more.
- Safe for mixed content. Text between tags is never re-indented, so documents keep their meaning.
- Handles real files. XML declarations, DOCTYPEs, comments, CDATA sections and namespaces.
- Private. Your XML stays in your browser.
Frequently asked questions
What does “well-formed” mean?
Well-formed XML follows the basic syntax rules: one root element, every tag closed in the right order, attribute values in quotes, no duplicate attributes, and special characters like & and < escaped. It is not the same as being valid against a schema (XSD or DTD), which this tool does not check.
Why is some content kept on one line?
When an element contains text mixed with tags, adding line breaks would change the text. Those elements are kept exactly as written; everything else is indented.
Can I format HTML with it?
Only XHTML or other HTML that is also well-formed XML. Regular HTML allows unclosed tags like <br> and <li>, which XML does not.
Are comments kept?
Yes when formatting. When minifying you can choose to remove them.
Is my XML uploaded?
No. Everything happens in your browser.
Last updated · Free, no sign-up, runs in your browser.