Skip to content

XML Formatter & Validator

Indents XML so it can be read, checks it for errors with the exact line, and can minify it again.

Your XML stays on this device

This tool runs entirely inside your web browser. Your XML is processed on your own device and is never sent to our servers. How this works

Comments, CDATA and the text inside elements are never changed — only the spacing between tags.

Tidied XML

XML Formatter & Validator turns cramped or machine-generated XML into something you can read, and tells you exactly where a file is broken and why. It can also go the other way and minify XML for sending. It works on any XML, including SVG images, RSS feeds, sitemaps and configuration files, and runs entirely in your browser.

How to format XML

  1. Paste your XML into the left box, or open a file.
  2. Any error appears with its line number and how to fix it. Click Show to jump to it.
  3. Choose an indent of 2 spaces, 4 spaces or tabs, then copy or download the result.
  4. Switch to Minify to strip the spacing out again.

What gets changed, and what does not

Only the whitespace between tags is rewritten. Comments, CDATA sections, entities such as&amp;, attribute order and spelling are all copied through exactly. An element that contains text, such as <p>Hello <b>there</b></p>, is kept on a single line, because in XML the spaces inside it may be part of the data and moving them could change the meaning.

Common errors and what they mean

Well formed is not the same as valid

This tool checks that your XML is well formed: tags match, nesting is correct, attributes are quoted. That is what catches nearly every real problem. It does not check a file against a schema (XSD) or DTD, which is a separate question about whether the right elements appear in the right places with the right values.

Related formats

For JSON use the JSON Formatter, and for configuration files theYAML Validator & Formatter. If you need to show XML or HTML as text on a web page, escape it first with the HTML Entity Encoder.

Frequently asked questions

What makes XML invalid?

Usually a tag that is never closed, closing tags in the wrong order, an attribute without quotes, or a bare < or & in text that should be written &lt; or &amp;. The checker names the problem and the line it is on.

Will formatting change what my XML means?

Only the spacing between tags is rewritten. Comments, CDATA sections, entities and the text inside elements are copied through exactly, and any element containing text stays on one line, because spaces there can be part of the data.

Does it check against a schema or DTD?

No. It checks that the XML is well formed, which is the usual problem. Checking a file against an XSD schema or DTD, to see whether the right elements appear in the right places, needs a validating parser.

Can I use it for SVG, RSS or a sitemap?

Yes. Those are all XML, so they can be tidied and checked here. A sitemap that a search engine rejects often turns out to have an unescaped & in a URL.

Is my file uploaded?

No. The XML is checked and reformatted in your browser, so API responses and configuration files never leave your device.

Last updated

Missing a feature, or need a tool we don’t have? Suggest it.