XML Formatter
Beautify XML indentation, minify whitespace, escape or unescape tag content, with live tag-pair validation.
How to Use
- Paste XML
Paste XML into the left box; formatting starts automatically by default.
- Switch actions
Choose Format, Minify, Escape or Unescape from the dropdown; formatting has adjustable indentation.
- Check validation
Tag and character counts appear under the result; invalid XML shows a specific error message.
FAQ
Does formatting change the XML semantics?
No. Formatting only adjusts line breaks and indentation between tags; tag names, attributes, text content, comments and CDATA stay untouched. Minify removes extra whitespace between tags only — whitespace inside tags, such as attribute values, is preserved.
What happens with invalid XML?
A built-in tag-pair validator checks for unclosed tags, mismatched closing tags and multiple root nodes, and reports the specific problem. If the XML is invalid, format and minify refuse to output rather than producing a plausible-looking but broken result.
Are CDATA and comments preserved?
Yes. <!-- comments --> and <![CDATA[...]]> blocks are kept as standalone chunks — never misparsed as tags, and < and & inside CDATA are not escaped.
When should I escape or unescape?
Escape when embedding user input or dynamic text into XML so <, >, & and quotes become legal entities; unescape to restore text taken out of XML to its original form. The tool unescapes all five entities: < > & " '.