XML Formatter: Format, Minify and Validate XML

Paste XML to pretty-print it, minify it, validate it, run XPath queries or convert it to JSON. Errors show the exact line and column.

Loading tool…

How to use the XML Formatter

  1. Paste your XML or upload a file.
  2. Choose Format, Minify, Validate, XPath or To JSON.
  3. Fix any error shown (line and column are given), or type an XPath expression.
  4. Copy or download the result.

About this tool

The tool first runs its own well-formedness check, which reports the exact line and column of problems such as a missing or mismatched closing tag, an unescaped ampersand, unquoted or duplicate attributes, text outside the root, or two root elements. Then your browser's XML parser rebuilds the document with consistent indentation, one element per line, attributes preserved and text kept inline.

Minify removes whitespace between tags; the XML declaration, comments, CDATA and processing instructions are kept, and text is trimmed at its edges, so avoid minifying documents where leading or trailing spaces matter. XPath mode uses your browser's XPath 1.0 engine (for example //book[price>500]/title or count(//book)). To JSON writes attributes as @name, mixed text as #text and repeated elements as arrays.

Validation means well-formedness only. It does not validate against an XSD or DTD, which would need a full schema engine, so a document can pass here and still be rejected by a system that enforces a schema. There is no collapsible tree view.

Frequently asked questions

What does well-formed mean?

The XML follows the basic syntax rules: one root element, properly nested and closed tags, quoted attributes and escaped special characters.

Does this validate against an XSD?

No. It checks well-formedness only, not schema rules.

Are the error positions reliable?

Yes. They come from the tool's own checker, so they do not depend on your browser's wording.

Can I test XPath?

Yes. Choose XPath and type an XPath 1.0 expression. Results are listed below.

Is my XML uploaded?

No. It is parsed and formatted entirely in your browser.

Need a custom tool or website?

IDM Valley builds web apps, calculators, AI chatbots and automation for businesses. Fixed prices, code in your name.

Get a free quote

Have a project in mind?

Tell us what you need: a website, landing page, AI chatbot or automation. You get a clear scope and a fixed price within one working day. Free, no obligation.


  • avshack
  • DivineBamboo
  • goldleaf
  • janapril
  • kaizen
  • kwc
  • modv
  • pixelrush
  • revital
  • riderzplanet
  • sandsfashions
  • avshack
  • DivineBamboo
  • goldleaf
  • janapril
  • kaizen
  • kwc
  • modv
  • pixelrush
  • revital
  • riderzplanet
  • sandsfashions