Skip to content

XML Formatter & Validator

Pretty-print or minify XML, find syntax errors and browse it as a tree

Loading the tool…

Formats XML that is on one line or badly indented, and when there is a syntax error, shows its line, column and how to fix it. Use it to read or repair configuration files, API responses, SVG, RSS and other XML.

How to use

  1. Paste XML into "XML input" or press "Open file". Correct XML shows "Well-formed XML"; otherwise "Not well-formed" appears with the position.
  2. Choose 2 spaces, 4 spaces or a tab under "Indentation", or "Minify" for one line. "Each attribute on its own line" and "Remove comments" are also available.
  3. On the "Tree" tab, expand and collapse elements and select one to "Copy XPath". On the "XPath" tab, press "Run" to evaluate an expression.
  4. The "JSON" tab shows the document converted to JSON. Copy a result or press "Save as .xml" or "Save as .json".

How it works

Questions and answers

How do I find where the error is in my XML?
An error comes with its line and column number, the cause and a hint for fixing it. Press "Go to the error" to jump to that spot in the input.
Why does an & character cause an XML error?
In XML a literal ampersand must be written as &. Only five entities are predefined, < > & " and ', so an HTML name such as   must be written as  .
Can I convert XML to JSON?
Yes, on the "JSON" tab. An id attribute becomes the key "@id", and an element with only text and no attributes becomes a plain string. Press "Save as .json" to download it.
How do I test an XPath expression?
Enter an expression such as //book/title or count(//book) in "XPath expression" on the "XPath" tab and press "Run". It runs on the browser's XPath 1.0 engine.