01What is XML Formatter?
XML Formatter re-indents or minifies an XML document without touching what it actually says. You paste a one-line SOAP response or a squashed config, pick Beautify or Minify, and press Format. That's it. Before any output appears, the tool checks that your document is well-formed under the W3C XML 1.0 rules. Every start tag needs a matching end tag in the right order. Attribute values must be quoted and can't repeat inside one tag. A bare & or < in text has to be escaped. Only the five predefined entities (< > & " ') and numeric references like   are accepted. The <?xml ...?> declaration must come first, and there must be exactly one root element. If anything breaks those rules you get the line number and a plain message, such as "expected </b> (opened on line 1) but found </a>". You get no output at all in that case, so you never copy a half-formatted broken file by accident. So how does it decide what to reformat? Only whitespace between elements counts as layout. Beautify puts each element on its own line, indented by 2 or 4 spaces. An element that holds text, CDATA or xml:space="preserve" is copied exactly as written. That means mixed content like <p>Hi <b>there</b></p> keeps its spaces, and a CDATA block containing x < y stays byte for byte. Start tags, attribute values, comments, processing instructions and the DOCTYPE are copied character for character too. A quick example. Feed it <catalog><book id="1"><title>XML</title><price>9.99</price></book></catalog> with indent 2. You get catalog on the first line, book indented two spaces, and title and price indented four, each on a single line with their values intact. Minify does the opposite. It removes whitespace between elements and drops comments, while text content stays exactly as it was. There are limits worth knowing. Entities declared inside a DOCTYPE aren't expanded, so an XHTML file that uses is reported as using an unknown entity. The parser stops at the first error, so a file with three problems needs three passes. It checks well-formedness only. It does not validate against an XSD or DTD, so a document with the wrong elements in the wrong places still formats fine. Long text inside an element is never re-wrapped either. Your XML is parsed by JavaScript in the page itself and is not uploaded.
Developers who read SOAP responses, edit Maven, Android or Spring XML by hand, or need to find the one unclosed tag that stops a config file from loading. The tool runs entirely in your browser, so your data never leaves your device.
02How to use XML Formatter
- Paste your XML into the input box
- Choose Beautify or Minify, and the indent size (2 or 4 spaces) for Beautify
- Click Format
- If an error appears, fix the line it names and format again
- Copy the formatted XML from the output
03Worked examples
- Input:
<catalog><book id="1"><title>XML</title><price>9.99</price></book></catalog> (Beautify, indent 2) - Result:
<catalog> <book id="1"> <title>XML</title> <price>9.99</price> </book> </catalog> - Elements that hold only text stay on one line, so their values are unchanged.
- Input:
<doc><p>Hi <b>there</b></p><empty/></doc> (Beautify, indent 2) - Result:
<doc> <p>Hi <b>there</b></p> <empty/> </doc> - <p> mixes text and an element, so it is copied exactly as written rather than split across lines.
- Input:
<a> <!-- c --> <b>1</b> <c><![CDATA[ x < y ]]></c> </a> (Minify) - Result:
<a><b>1</b><c><![CDATA[ x < y ]]></c></a> - Minify drops comments and layout whitespace but keeps CDATA content byte for byte.
- Input:
<?xml version="1.0"?> <!-- note --><cfg><db host="x" port="5432"/><log level="info">on</log></cfg> (Beautify, indent 4) - Result:
<?xml version="1.0"?> <!-- note --> <cfg> <db host="x" port="5432"/> <log level="info">on</log> </cfg> - The declaration and the top-level comment each get their own line. Attributes are copied exactly as typed.
- Input:
<a><b></a> - Result:
Line 1: expected </b> (opened on line 1) but found </a> - Input:
<a>Tom & Jerry</a> - Result:
Line 1: "&" must be written as & - A bare ampersand is allowed in most HTML but makes XML not well-formed.
04Common use cases
- Making a single-line SOAP or REST XML response readable while debugging
- Re-indenting a Maven pom.xml or Android layout file after a merge
- Finding the unclosed or mismatched tag that stops a config file from loading
- Minifying an XML payload or sitemap before embedding it in a test fixture
- Checking that a hand-edited Spring or log4j XML file is well-formed before restarting the app
- Cleaning up an XML snippet before pasting it into a code review or a bug report
05Tips
- Whitespace inside text is never changed; only the line breaks and indentation between elements are rewritten
- Elements with text content stay on one line exactly as written, so long paragraphs in mixed content are not re-wrapped
- Minify removes comments; use Beautify if you need to keep them
- Replace HTML entities such as with numeric references ( ) unless your XML is processed with its DTD
- The formatter stops at the first error, so after fixing one line press Format again to see if another problem is hiding further down
06Related concepts
XML Schema, XSLT, XPath, SAX parser.
Frequently Asked Questions
What is XML Formatter?
XML Formatter is a free, browser-based developer tool on AIDToolStack. Format, indent, and minify XML with tag error detection. It requires no installation or sign-up and works entirely in your browser.
Is XML Formatter free to use?
Yes. No sign-up, no fees and no usage cap.
Does XML Formatter store my data?
No. It runs in your browser; nothing is uploaded.