XML formatter and validator
Indent, validate and minify XML, query the document with XPath and convert it to JSON without leaving your browser.
Well-formed XML
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns:dc="http://purl.org/dc/elements/1.1/">
<book id="bk101" lang="es">
<dc:title>Guía de XML & XPath</dc:title>
<author>Ada Lovelace</author>
<price currency="EUR">29.95</price>
<tags>
<tag>xml</tag>
<tag>datos</tag>
</tags>
<!-- edición revisada -->
</book>
<book id="bk102" lang="en">
<dc:title>Clean Feeds</dc:title>
<author>Alan Turing</author>
<price currency="USD">19.5</price>
<summary><![CDATA[Uses <rss> & <atom>]]></summary>
</book>
</catalog>
What it checks and limits
- Checks well-formedness (closing tags, single root, quotes, duplicate attributes, entities and comments). It does not validate against a DTD or XSD.
- Mixed content (text and tags together), CDATA and elements with xml:space="preserve" are left untouched so data is not altered. Elements containing only whitespace are emptied.
- The tester uses your browser's XPath 1.0 engine.
- Everything happens in your browser: the XML is never sent to a server.
Built by
Miguel Ángel Colorado Marin (MACM)
Built by
Miguel Ángel Colorado Marin (MACM)
Full-Stack Developer · Guadalajara, España
I develop web apps, digital tools and full projects — from design to deployment.
XML is still everywhere: RSS feeds, sitemaps, SVG, electronic invoices, Android and .NET configs or SOAP responses. When it arrives on a single line or with an error, spotting it by eye is impossible. This formatter parses the document with its own parser that checks well-formedness and points to the exact line and column of each problem with an explanation. When indenting it respects what matters in XML: mixed content, CDATA blocks and elements marked xml:space="preserve" are left untouched. You can also minify it, test XPath expressions against the document and convert it to JSON.
Features
- ✓Well-formed XML validation with a clear message, error line and column
- ✓Formatting with 2, 4 spaces or tab, attributes on lines and configurable width
- ✓Mixed content, CDATA and xml:space="preserve" left untouched so data is not altered
- ✓Empty elements as <a/> or <a></a>, attribute sorting, double quotes and comment removal
- ✓Minification that preserves the data tree and shows byte savings
- ✓XPath 1.0 tester with the document's own namespace prefixes
- ✓XML to JSON conversion with configurable attribute prefix, text key and arrays
- ✓Internal DTD entities recognized and support for SVG, RSS, Atom, sitemaps and plist
How do I format and validate XML?
- 1
Paste or open the XML
Paste the document or open an .xml, .svg, .rss or similar file. You will see instantly whether it is well-formed.
- 2
Choose the action
Format, minify, convert to JSON or test an XPath expression.
- 3
Adjust the options
Indentation, attributes, empty elements, comments or JSON convention.
- 4
Copy or download
Copy the result or download it as a file.
Frequently asked questions
What does well-formed XML mean?
That it follows XML syntax: a single root element, every tag closed and properly nested, quoted and unique attributes, and & and < escaped. It is different from being valid, which requires matching a specific DTD or XSD schema.
Why does fail in XML?
XML only defines five entities: &, <, >, " and '. comes from HTML. Use the numeric reference   or declare the entity in the document's DTD.
Why isn't some content indented?
If a tag mixes text and elements, adding line breaks would change the data. The same applies to CDATA and xml:space="preserve". The formatter leaves them exactly as they were.
How do I use XPath with namespaces?
Prefixes declared in the document, such as xmlns:dc, can be used directly: //dc:title. For elements in the default namespace use the d: prefix (//d:item) or local-name(): //*[local-name()='item'].
How is XML converted to JSON?
Each element becomes a key. Attributes get a prefix (@ by default), text alongside attributes or children goes in #text and repeated children are grouped into arrays. You can change the prefix, the text key or always force arrays.
Is my XML uploaded?
No. Parsing, formatting, XPath and conversion run in your browser.
Related tools
Embed XML Formatter and Validator on your site
Add XML Formatter and Validator to any web page with a simple iframe. Free, with attribution to miguelacm.es.
<iframe
src="https://miguelacm.es/embed/xml-formatter"
width="100%"
height="700"
frameborder="0"
title="XML Formatter and Validator — miguelacm.es"
></iframe>View embed in new tab →