Development Tools
XML Formatter and Validator
Paste XML, or open an XML file, to check that it is well-formed and to re-indent it with two spaces, four spaces or tabs. If something is wrong, the tool names the problem and shows the line and column: mismatched tags, unquoted attributes, unescaped ampersands, a second root element, unclosed comments. You can also minify the document or strip comments. It checks well-formedness only. It does not validate against a DTD or an XSD schema, and it never fetches external entities or other files.
How to use it
- Paste the XML or open a file.
- Pick an indent size and press Format, or press Minify.
- Copy the result or download it. If the XML is invalid, fix the line and column shown.
Example
<a><b>hi</b></a> is formatted onto three lines, while <a><b></a> is rejected with “Mismatched tag: expected </b> but found </a>”.
Common XML mistakes
- An & that is not escaped as &, often in URLs inside attributes or text.
- Attribute values without quotes, or with mismatched quote marks.
- Tags that are closed in the wrong order, or a missing closing tag.
- A byte-order mark or text before the <?xml?> declaration.
Which tool fits your task?
This page is for checking and indenting XML.
- JSON Viewer: for validating and formatting JSON, not checking and indenting XML.
- SQL Formatter: for tidying SQL queries, not checking and indenting XML.
- CSV Viewer and Cleaner: for sorting, filtering and cleaning a CSV file, not checking and indenting XML.
- JSON to CSV and CSV to JSON Converter: for converting between JSON and CSV, not checking and indenting XML.
Questions
What is the difference between well-formed and valid?
Well-formed means the XML follows the basic syntax rules. Valid means it also conforms to a schema such as a DTD or XSD. This tool checks only the first.
Can it check my XML sitemap?
It can confirm the XML is well-formed. For sitemap rules such as the URL limit and protocol, use the sitemap validator on this site.
Does formatting change my data?
Only whitespace between elements. Text inside elements is kept as it is, apart from tidying line breaks inside it, so check mixed-content documents.
Does it follow external entities or DOCTYPE links?
No. A DOCTYPE is kept as written but never fetched, so XML external entity attacks do not apply.
How large a file can I use?
Up to about 10 million characters. Very large files may be slow to format in a browser.
Get practical SEO tips by email
Occasional emails with new guides and tools. Confirm by email first; unsubscribe in one click.