Skip to content
Browser tool Runs locally

XML Tools

Format, minify, validate, diff, and convert XML in your browser.

Tools

Validator vs. Formatter & Validator

Both tools check whether your XML is well-formed, but they return different things. XML Validator gives you a fast pass/fail with an error location, and nothing else, useful when you're checking output from a script or pipeline and don't need to see the document itself. XML Formatter & Validator runs the same check but also re-indents the document, so use it when you plan to read, edit, or hand the file to someone else afterward.

Which XML tool should I use?

XML gotchas worth knowing

  • Namespaces. A prefix like ns:element only means something if it's bound to a URI via xmlns:ns="...". Two elements with the same local name but different namespaces are different elements, even though they look identical.
  • CDATA sections. <![CDATA[ ... ]]> tells the parser to treat the content as raw text, not markup, so < and & inside it don't need escaping. Useful for embedding HTML or code snippets inside an XML document.
  • Escaping. Five characters need entity references in text content: & (&amp;), < (&lt;), > (&gt;), " and ' inside quoted attribute values. An unescaped & or < is the most common cause of a well-formedness error.
  • Empty elements. <tag></tag> and <tag/> are equivalent to a parser, but not always to every downstream tool. Formatters and minifiers may normalize one to the other, which is worth checking if a consumer expects a specific form.

XML → JSON → XML round trips

Converting XML to JSON and back doesn't always reproduce the original file, because JSON has no native concept of attributes, namespaces, or the difference between element order and object key order. Depending on how the conversion maps attributes (commonly into a prefixed key like @attr), a round trip can flatten namespace prefixes, reorder sibling elements, or turn a single child element into an array only when there happen to be two or more of them, which can silently change how the output is interpreted downstream. If a round trip needs to be exact, compare the original and converted files with XML Diff & Compare rather than assuming it matches.

Frequently asked questions

What's the difference between "well-formed" and "valid" XML?
Well-formed means the syntax is correct: tags are properly nested and closed, there's exactly one root element, and attribute values are quoted. Valid means the document also conforms to a schema or DTD (specific elements, attributes, and structure). These tools check well-formedness, not validation against a schema.
Why are there both an XML Validator and an XML Formatter & Validator?
The Validator only reports whether the document is well-formed and where it breaks. The Formatter & Validator does the same check but also returns re-indented output, so use it when you want to read or reuse the document afterward.
Will converting XML to JSON and back give me the same file?
Not always. XML has constructs JSON has no equivalent for, so a round trip can shift or drop them, see the round-trip notes above. Use XML Diff & Compare on the original and the round-tripped file to see exactly what changed.
Why does my XML fail validation when it looks fine?
Common causes: an unescaped & or < inside text content, a self-closing tag missing its trailing slash, mismatched case in a closing tag (XML is case-sensitive), or more than one root element.