About XML Formatter
Pretty-print XML so it is easy to read and diff. The tool first checks that your document is well-formed, then indents elements, comments and processing instructions. It never changes the meaning of the document: text, entities, attribute quotes and mixed content such as <p>Hello <b>world</b></p> are kept exactly as written.
How to use XML Formatter
- Paste XML, or open an .xml, .svg or .rss file.
- Choose 2 spaces, 4 spaces or a tab for indentation.
- Optionally tick Trim spaces around text-only values.
- Copy the result or download formatted.xml.
Tips and good to know
- Whitespace can matter in XML, so trimming text is off by default.
- Elements that mix text and tags stay on one line on purpose, because adding line breaks would add text.
- Documents with errors are not formatted; fix the reported line and column first.
Well-formed XML
XML must have exactly one root element, every opened tag must be closed, tags are case-sensitive and must nest properly, and attribute values need quotes. Special characters & and < must be escaped in text. Formatting only adds indentation and line breaks, so it never changes the data, although whitespace inside mixed-content elements can matter in some documents.
Well-formed XML in brief
XML is strict: every opening tag needs a matching closing tag (or is self-closing like <br/>), tags must nest properly, attribute values must be in quotes, and there must be exactly one root element. Names are case-sensitive, so <Item> and <item> are different. Special characters in text must be escaped: & as & and < as <.
XML is still widely used in sitemaps, RSS feeds, Office documents (a .docx is a ZIP of XML files), SVG images and many enterprise and government data exchanges.
Frequently asked questions
Does it validate against a schema?
No. It checks that the XML is well-formed. It does not check a DTD or XSD.
Are external entities loaded?
Never. Entities declared in a DOCTYPE are neither fetched nor expanded, and a note appears if a file or URL entity is found.
Is XML Formatter free?
Yes. XML Formatter is free: no sign-up, no paid plan, no trial and no limit on how often you use it. It runs in your browser, and ToolzAura is paid for by ads, so every tool stays free.
Are my files uploaded?
No. This tool runs in your browser, so your input stays on your device.