XML Formatter

Pretty-print or minify XML while checking that every tag is closed

Runs in your browserUtility01Formatters & Validators

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

  1. 1Paste your XML, with or without an XML declaration.
  2. 2Choose an indentation width and the tool re-lays out the document by node depth.
  3. 3If a tag is left open or an entity is malformed, you get the exact parser error.
  4. 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

SymptomCauseFix
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 mismatchA 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 tools