XML formatter
Pretty-print / minify / validate XML using the browser parser
Paste XML and choose Pretty-print or Minify. Mixed content is preserved so added line breaks do not change meaningful text.
Example
Input
<root><item id="1"/><item id="2"/></root>
Example result
<root> <item id="1"/> <item id="2"/> </root>
Use two-space indentation. The result is for reading, not byte-for-byte preservation.
Technical details & limits
DOMParser and XMLSerializer may normalize quotes, entity representations or declarations. Indentation is applied to element-only containers; mixed content and xml:space="preserve" are left intact. This checks syntax, not XSD/DTD validity or signature canonicalization.
About this tool
Check XML well-formedness and create indented or compact views. Inspect API messages, configuration and nested nodes while preserving mixed text and xml:space content.
Use cases
- Blow up a compact XML response so it reads.
- Check whether an XML document is well-formed.
How to use
- Paste XML into the input.
- Click Pretty-print or Minify.
Notes
Well-formedness only — no XSD / DTD validation. CDATA and comments are kept as-is.
FAQ
- Does XML formatting change whitespace inside mixed text content?
- This formatter indents element-only containers while preserving text whitespace inside mixed content. For example, 1 text node combined with 2 child elements should not acquire arbitrary formatting spaces. Regions using the XML space-preservation setting are also kept intact. Review business-sensitive text after formatting, because parsing and serialization can still change other representations such as attribute quotes or entity notation without preserving the original bytes.
- Can the XML syntax checker validate XSD or DTD rules?
- This tool checks whether XML is well formed; it does not perform XSD or DTD validation. A document with 2 top-level elements or 1 unclosed tag has a syntax problem. Passing the parser does not prove that element order, field types, or mandatory values satisfy a business schema. Use a schema-aware validator for those rules, and keep syntax validation separate from application-level acceptance of the document.
- Can formatted XML be used directly for a digital signature?
- Formatted XML is not a substitute for the canonical representation required by a digital signature protocol. Parsing can change attribute quoting or entity notation; for example, A and A are 2 representations of A with different source bytes. Follow the canonicalization rules specified by the signing system. Do not assume that visually equivalent XML will produce the same digest after ordinary formatting and serialization.
Related tools