XML Formatter
Pretty-print & indent XML.
XML Formatter at a glance
XML Formatter is a free online developer tool you can use right now to pretty-print & indent XML โ no account, no install and no usage limit. It runs entirely inside your browser, so whatever you enter stays on your own device.
- Price
- Free โ no trial, no paid tier, no watermark
- Sign-up
- Not required
- Where it runs
- In your browser โ nothing is uploaded to a server
- Works on
- Chrome, Safari, Firefox and Edge โ desktop, tablet and phone
- Category
- Developer Tools
About XML Formatter
Paste minified or badly indented XML and get it back properly nested, with each level indented so the structure is readable. Malformed markup is flagged rather than silently mangled.
XML is stricter than HTML in ways that cause most of the errors people hit. Every element must be explicitly closed โ there is no equivalent of an unclosed <li>. Tag names are case-sensitive, so <Item> and <item> are different elements. Attribute values must always be quoted. And there must be exactly one root element containing everything else; two top-level siblings make a document that no parser will accept.
The five reserved characters are the other frequent source of breakage: < > & ' and ". An ampersand inside text content must be written & even in a URL, which is why a query string pasted directly into an XML element so often produces a parse error. Content that genuinely needs raw characters belongs in a CDATA section.
If you are working with RSS feeds, sitemaps, SOAP payloads or Android layouts, all of these rules apply โ those are all XML, and a sitemap rejected by Search Console is very often an unescaped ampersand in a URL.
How to use XML Formatter
- Paste your XML into the box.
- It is parsed, validated and re-indented automatically.
- Copy the formatted result, or fix any structural error that is reported.
Frequently asked questions
Why does my XML fail to parse?
The usual causes are an unescaped ampersand in text or a URL, an unclosed tag, mismatched case between opening and closing tags, an unquoted attribute value, or more than one root element. XML is far stricter than HTML about all five.
Which characters have to be escaped?
Five: & becomes &, < becomes <, > becomes >, " becomes " and ' becomes '. The ampersand is the one that catches people, because URLs in feeds and sitemaps are full of them.
What is a CDATA section for?
It marks a block whose content should not be parsed as markup, so raw < and & characters are allowed. It is the usual way to embed HTML inside an RSS description without escaping every character.
Can I format an RSS feed or sitemap with this?
Yes โ both are XML and follow the same rules. It is a quick way to check why a sitemap was rejected, which is very often an unescaped ampersand inside a URL.