How to use the XML Formatter
- 1. Paste XMLSOAP responses, sitemaps, Android layouts, RSS or config files.
- 2. Choose outputPretty print with 2 spaces, 4 spaces or tabs, or minify.
- 3. Copy or downloadGet the formatted XML or the exact parser error.
Formatting and checking
XML from APIs and logs often arrives as one long line, which is impossible to read. The formatter puts each element on its own line with indentation that shows nesting. Short elements that only hold text, like <title>Python Basics</title>, stay on one line so the result is compact. Empty elements are written self-closing, like <course id="sql201"/>. Comments, CDATA sections, processing instructions and the <?xml …?> declaration are kept.
Before formatting, the XML is parsed by your browser's strict XML parser. If it is not well-formed, for example a tag is not closed or an & is not escaped, you get the parser's error message instead.
Worked example
The sample is a one-line course catalogue with 8 elements: catalog, two course elements, title, fee, topics and two topic elements. Pretty-printed with 2 spaces, it becomes:
<catalog>
<course id="py101" level="beginner">
<title>Python Basics</title>
<fee currency="INR">15000</fee>
…Minify does the reverse: it removes the whitespace between tags to make the smallest file for sending over a network. Note that whitespace inside text is kept, because in XML it can be meaningful. If the parser reports an error, the message usually names the line and column, so fix that spot and format again. Large files of several megabytes still format quickly, because the work happens on your own device.
Frequently asked questions
What does well-formed mean?
Every tag closes, tags nest properly, there is one root element, attribute values are quoted and special characters are escaped.
Does it validate against an XSD?
No. It checks that the XML is well-formed, not that it follows a particular schema.
Will it change my data?
Only whitespace between tags changes. Element names, attributes and text stay the same.
Is the xml formatter free?
Yes, it is free. Formatting your first XML asks for your name and WhatsApp number once, and after that the xml formatter and every other Uncodemy tool open without the form.