๐
XML Formatter
Developer
Format or minify well-formed XML without DTD or XSD validation.
0
0
Input
Checks well-formedness, not XSD or DTD validity. DTD declarations are unsupported. Minify removes whitespace between child elements; mixed text, CDATA and xml:space="preserve" are retained.
Output
XML formatter that re-indents well-formed XML with 2 or 4 spaces, and Minify strips the whitespace between elements. Paste your XML, choose Format or Minify, and copy the result.
See moreSee less about the XML Formatter
It checks well-formedness only, with no DTD or XSD validation.
Examples
Format with 2 spaces
<root><item id="1">Hello & welcome</item><item>Two</item></root>
โ
<root>
<item id="1">Hello & welcome</item>
<item>Two</item>
</root>Entities such as & stay escaped. Comments and CDATA sections are kept.
Broken markup
<root><item></root> โ parser errorThe message comes from the browser XML parser, so its wording varies. Documents with DTD declarations are rejected.
Key features
- Format with 2 or 4 spaces
- Minify
- Well-formedness check
- Copy output
Related Blog Posts
Quick answers for XML Formatter
How does it detect invalid XML?
It parses your input with the browser's built-in DOMParser and checks for a parsererror node, flagging the specific parsing failure instead of just failing silently.
What does Minify remove?
Whitespace between child elements is removed where it is not mixed text. Mixed text, CDATA and xml:space="preserve" are retained.
What indentation options are available?
You can choose between 2-space and 4-space indentation, and attribute values and text content are properly escaped for characters like &, <, and " during formatting.
Does this validate a schema?
No. It checks XML well-formedness. DTD declarations are rejected and XSD validation is not supported.