About the XML Formatter
Make XML readable again or shrink it for transfer. If the XML is broken, the parser’s error message helps you find the problem in sitemaps and feeds.
XML still runs a large part of the web and of business software: sitemaps, RSS and Atom feeds, SOAP services, Android layouts, Office files and many configuration formats. It is often delivered as one huge line, which makes errors and structure impossible to see. This formatter re-indents XML so the tree is readable, or minifies it when you need it small.
The input is parsed with the browser’s XML parser, which also checks that the document is well-formed: every tag closed, attributes quoted and only one root element. If something is wrong, the parser’s message tells you what and roughly where. Comments and CDATA sections are preserved, and you can indent with 2 spaces, 4 spaces or tabs.
How to use the XML Formatter
- 1Paste XML.
- 2Choose Format or Minify and the indent.
- 3Copy or download the result.
Key features
- Pretty-print with 2 spaces, 4 spaces or tabs.
- Minify to one line.
- Well-formedness check with parser errors.
- Keeps comments and CDATA.
- Copy or download the result.
Practical uses
- Inspecting a sitemap.xml before submitting it to Google.
- Reading an RSS feed to check its items.
- Debugging SOAP requests and responses.
- Tidying Android or Maven configuration files.
- Checking the structure of a .docx or .xlsx part after unzipping it.
Example
A one-line sitemap with three <url> entries becomes a neatly nested document: <urlset> at the top, each <url> indented once and its <loc> and <lastmod> indented twice, which makes a missing <loc> easy to spot.
Tips and common mistakes
- An “extra content at the end” error usually means two root elements; wrap them in one parent.
- Escape & as & inside text and attribute values.
- Check the encoding declaration if special characters look wrong.
Limitations
- Validation against an XSD or DTD is not performed.
- Whitespace inside mixed-content elements may change when formatting.
Privacy
XML is parsed and formatted in your browser. Feeds, invoices or API messages you paste are never uploaded.
Frequently asked questions
Does it validate XML?
It checks that the XML is well-formed (tags closed, quotes matched). It does not check against an XSD schema.
Are comments kept?
Yes, comments and CDATA sections are kept when formatting.
Is there a size limit?
Files of several megabytes work fine in modern browsers.
Can I convert the XML to JSON?
Yes, with the XML to JSON tool in Data Tools.
Are attributes reordered?
No. Attributes stay in their original order; only indentation and line breaks change.
Does minify remove comments?
Minify removes whitespace between tags. Comments are kept so no information is lost.