XML Formatter & Validator

Pretty XML, compact XML, and a straight answer on validity.

Runs in your browser. Nothing is uploaded — your input is processed on this device and discarded when you close the tab.

XML Formatter & Validator

How to use this tool

  1. Paste XML into the first box.
  2. Choose Pretty-print, Minify or Validate. Pretty-print uses 2-space indentation; minify strips whitespace between tags.
  3. Read errors literally: invalid XML is rejected with the parser's message, not silently repaired.

Worked example

With the sample <note><to>Ana</to><body>Hi</body></note>, Pretty-print produces a four-line indented document with <to> and <body> nested under <note>, and Minify returns the same single line back. Validate reports “Valid XML.” Feed it <note><to>Ana</note> instead (a missing </to>) and validation fails with the parser's error text, naming the mismatch.

What this tool does not do / Limits

This tool formats and validates structure only. It does not check XML against a schema or DTD, does not resolve external entities, and does not fix broken input — a document with a mismatched tag stays broken until you correct it. Formatting assumes the input is XML; HTML with unclosed tags will be rejected or formatted oddly, which is correct behaviour for an XML tool.

Frequently asked questions

What is the difference between pretty-printing and minifying?

Pretty-printing adds indentation and line breaks so a human can read the structure. Minifying removes whitespace between tags so the file is smaller. The data is the same either way.

Why does validation fail on HTML?

Because HTML allows unclosed tags and other shortcuts that XML forbids. XML requires every opening tag to be closed, exactly one root element, and quoted attributes.

Related tools