How to Format and Validate XML Online (Pretty Print or Minify)
Make one-line XML readable, find the exact line of a syntax error, or minify XML — for sitemaps, RSS feeds, SVG and config files.
XML is still everywhere: sitemaps, RSS feeds, SVG images, Android and Maven configs, SOAP APIs and office documents. It is often delivered on a single line, which makes it hard to read, and one missing closing tag makes the whole file invalid.
Well-formed XML in a nutshell
- Every opening tag has a matching closing tag, or is self-closing like
<br/>. - Tags are properly nested:
<a><b></b></a>, not<a><b></a></b>. - There is exactly one root element.
- Attribute values are quoted, and special characters such as & are escaped as
&. - Tag names are case-sensitive —
<Item>and<item>are different.
How to format or validate XML
- Open the XML Formatter.
- Paste XML or open a file (XML, SVG, RSS, sitemap or config).
- If it is well-formed, choose 2 spaces, 4 spaces or tabs and click Format — or Minify to strip whitespace.
- If it is not, the browser's XML parser reports the error with its line and column.
Comments, CDATA sections, processing instructions and the XML declaration are preserved when formatting.
Common XML errors
- "Opening and ending tag mismatch" — a tag was closed in the wrong order or misspelled.
- "EntityRef: expecting ;" — a raw & in text; replace it with
&or wrap the text in CDATA. - "Extra content at the end of the document" — there is more than one root element.
Working with HTML instead? Use the HTML, CSS & JS Formatter.
Frequently Asked Questions
What is the difference between valid and well-formed XML?
Well-formed XML follows XML syntax rules such as matching tags and one root element. Valid XML additionally matches a schema (XSD or DTD). This tool checks well-formedness.
Does formatting change my data?
No. Formatting only changes indentation and line breaks; comments, CDATA and the XML declaration are kept.
Can I format an SVG or sitemap?
Yes. SVG files, RSS feeds and sitemaps are XML and can be formatted and validated the same way.
Is my XML uploaded?
No. It is parsed by your own browser and never sent to a server.
