XML Formatter
The XML Formatter tidies XML into neat indented lines or packs it into one line, and checks it is well formed as you type. If something is wrong, it names the line and column and says how to fix it. It is for developers, SEO staff checking sitemaps and anyone reading a feed or config file.
Paste XML to check and format it.
Your XML is checked on this device and never uploaded.
What is the XML Formatter?
The XML Formatter reads pasted XML, such as a sitemap, an RSS feed, a SOAP or API reply, an Android layout or a config file, and checks it against the well-formedness rules of the W3C XML 1.0 standard: exactly one root element, every tag closed in the right order, attribute values in quotes and not repeated, and every & written as a proper reference such as &. When the XML is fine it shows it indented by 2 spaces, 4 spaces or tabs, or minified to one line, with the element count, depth and size before and after. When it is not, it shows the line and column, the broken line with a marker under the spot, and a plain fix such as "</order> does not match the open tag <item> from line 1. Close <item> first." Text inside elements is never changed: elements that mix text and tags, and anything marked xml:space="preserve", are kept exactly as written.
Who it is for: Developers working with APIs, feeds and config files, SEO staff checking XML sitemaps, and students learning XML.
How to use the XML Formatter
- Paste your XML into the box.
- Read the check: well-formed, or the line and column of the first error.
- Choose formatted or minified output and the indent you want.
- Copy the result or download it as an .xml file.
Why use it
- Errors you can findLine, column and a marker under the exact spot, with a plain fix.
- Format or minify2 spaces, 4 spaces or tabs, or one compact line.
- Your text kept safeText and mixed content are never rewritten, only the spacing between tags.
- PrivateChecked in your browser; nothing is uploaded.
At a glance
- What you put in
- Pasted XML text, up to 5 MB; output style, indent, comment and empty-element options
- What you get
- Formatted or minified XML to copy or download, the element, attribute and depth counts, size before and after, or the line, column and fix for the first error
- Limits
- Checks well-formedness only, not a DTD or XSD schema; entities other than the five built-in ones are accepted only when the file has a DOCTYPE; 5 MB
- Privacy
- Runs in your browser. Nothing you enter is uploaded or stored.
- Price
- Free for everyone. No subscriptions, no payments, no watermark.
- Works offline
- Yes, once the page has loaded
- Last checked
- by AK Shine
Worked example
One line: <?xml version="1.0" encoding="UTF-8"?><catalog><!-- spring list --><book id="b1" lang="en"><title>Dune</title><price currency="USD">9.99</price></book><book id="b2"/></catalog> (176 bytes), formatted with 2 spaces.
Well-formed XML: 5 elements, 4 attributes, 3 levels deep. 176 bytes in, 200 bytes out (14% larger). The result has 9 lines: the declaration, <catalog>, the comment, <book id="b1" lang="en">, <title>Dune</title>, <price currency="USD">9.99</price>, </book>, <book id="b2"/> and </catalog>, each indented 2 spaces per level.
Formatting adds line breaks and spaces, so the file grows. Minified, the same XML is back to 176 bytes. If you change </book> to </catalog>, the check reports line 1 and says </catalog> does not match the open tag <book>.
When to use something else
- It checks that XML is well formed, not that it follows a schema. To test against an XSD or DTD, use a validator in your editor or build tools, such as xmllint.
- Entities such as are not part of XML. They pass only when the file has a DOCTYPE that could declare them; otherwise write  .
- The formatter does not change text inside elements, so an element whose text already has line breaks keeps them.
- To turn JSON into XML, use JSON to XML.
Questions people ask
What does well-formed XML mean?
Well-formed XML follows the basic grammar of the XML 1.0 standard: one root element, every start tag closed in the right order, attribute values in quotes, no attribute repeated in a tag, and & and < written as & and < in text. Any XML reader must refuse a file that breaks these rules.
What is the difference between well-formed and valid XML?
Well-formed means the syntax is correct. Valid means it is well formed and also follows a DTD or XML Schema that lists which elements and attributes are allowed. This tool checks well-formedness; schema checks need the schema file, such as with xmllint.
Why does my XML say a tag does not match?
Tags must close in the reverse order they opened. In <order><item>Pen</order>, </order> arrives while <item> is still open. The tool names the open tag and its line, so add </item> before </order>.
Why is an error in XML?
XML knows only five named entities: & < > " and '. Names like come from HTML. Use the number instead,   for a non-breaking space, or declare the entity in a DOCTYPE.
Does minifying XML change the data?
It removes line breaks and spaces between tags, which XML readers ignore, and can drop comments. Text inside elements is kept. Elements that mix text and tags, and xml:space="preserve" elements, are copied exactly, because spaces there can matter.
Can I format an XML sitemap or RSS feed?
Yes. Open the sitemap or feed in your browser, view the page source, copy everything and paste it here. The check also catches common sitemap breakers, such as a bare & in a URL, which must be written &.
Is there a size limit?
Up to 5 MB of pasted text. Formatting happens in your browser, so very large files can take a moment on a phone. Split bigger files and check them in parts.