XML formatter

XML formatter

Pretty-print / minify / validate XML using the browser parser

Computed in your browser

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

  1. Paste XML into the input.
  2. Click Pretty-print or Minify.

Notes

Well-formedness only — no XSD / DTD validation. CDATA and comments are kept as-is.

FAQ

Does well-formed XML satisfy my business schema?
Not necessarily. Correct nesting and syntax only make a document parseable. Types, required elements and ordering constraints need the target schema or application validation.
Can XML and HTML be validated using the same rules?
No. XML has stricter nesting, case and attribute-quoting rules. This uses an XML parser, not an HTML formatter.
Why are some nodes not split across lines?
Spaces in mixed content may be part of the text, and xml:space may require preservation. Those subtrees are left intact.
Can formatted XML be used directly for signature verification?
Do not assume so. Serialization can alter whitespace, attribute representation or declarations. Signatures may require specific canonicalization; retain the original and follow the signing protocol.

Related tools

XML formatter · Pretty-print / minify / validate XML using the browser parser
XML formatter — Tool illustration · dayeku.com