XML Formatter
Pretty-print or minify XML while checking that every tag is closed
What is XML Formatter?
An XML formatter expands compact XML into an indented tree and, while parsing, verifies that tags are properly closed and entities are correctly escaped. It is a common way to read payment callbacks, SOAP envelopes, and Maven configuration, and the parsing happens locally in your browser.
How to use XML Formatter
- 1Paste your XML, with or without an XML declaration.
- 2Choose an indentation width and the tool re-lays out the document by node depth.
- 3If a tag is left open or an entity is malformed, you get the exact parser error.
- 4Use "Minify" to collapse the document into a single whitespace-free line for config files or request bodies.
How do I do this in code?
Use the tool above for one-off work; for anything you repeat, move it into a script or your project.
# Pretty-print xmllint --format input.xml # Check that the document is well-formed xmllint --noout input.xml && echo OK
Common errors and how to fix them
| Symptom | Cause | Fix |
|---|---|---|
| EntityRef: expecting ; | A bare & appears in a text node, but XML requires it to be written as &. | Escape & as &, or wrap the whole block in a CDATA section. |
| Opening and ending tag mismatch | A pair of tag names differ in case, or a tag was never closed — XML is strictly case-sensitive. | Check the spelling and casing of the paired tags at the position the error reports. |
Frequently asked questions
Are XML and HTML formatted by the same rules?+
No. XML requires every tag to be closed, is case-sensitive, and demands quoted attribute values, whereas HTML lets you omit many closing tags. That is why feeding an HTML fragment to an XML parser usually errors out — the behavior is expected rather than a bug.
Can it format long SOAP messages?+
Yes. A SOAP message is XML underneath, so the tool indents it by Envelope, Header, and Body, which makes finding a specific field much easier. Nothing is uploaded, so it is safe to use on real messages that contain business data.
Related tools
All toolsJSON Formatter
Format, minify, and validate JSON with line-and-column error reporting
JSON Validator
Validate JSON syntax and pinpoint the failing line and column
JSON Viewer
Explore JSON as a collapsible tree and read off access paths
JSON Escape / Unescape
Escape and unescape JSON strings
SQL Formatter
Beautify SQL per dialect, including MySQL and PostgreSQL
YAML Formatter & Validator
Validate YAML syntax and normalize the indentation