Tool guide
About this tool.
XML describes a document with named elements, attributes and text; formatting makes an element hierarchy easier to inspect.
This formatter parses the document first, then adjusts layout between structural nodes. Text-only elements, mixed content, CDATA and xml:space="preserve" regions stay intact.
- Read a compact XML response, configuration or exported document without manually adding line breaks.
- Check matching tags, quoted attributes, character references and a single document root before copying the result.
- Apply consistent indentation while keeping sentences with inline tags and protected whitespace unchanged.
Paste one well-formed XML document or choose a sample. Use XML, not HTML with optional closing tags.
Choose 2 spaces, 4 spaces or Tabs under Indentation, then select Run XML Format.
If parsing fails, use the line and column in the error to fix the unclosed tag, unquoted attribute or undefined entity, then run again.
Inspect the formatted hierarchy, then copy it or save formatted.xml. Mixed-content regions may remain on one line to avoid changing their text.
- <root><item/><item>Text</item></root> → the two item elements appear on separate indented lines.
- <p>Hello <strong>world</strong>!</p> → stays inline; no spaces or line breaks are inserted into the sentence.
- <item note="a > b">A & B</item> → the quoted > and the original entity spelling stay unchanged.
- <code xml:space="preserve"> first\n second </code> → the whitespace inside code stays exactly as supplied.
- Processing is local. DOCTYPE and DTD declarations are rejected; external entities and schemas are never fetched.
- Whitespace used only as layout between element children is normalized. Leaf text, mixed content, CDATA, entity spellings, comments, attribute order and quote styles are retained.
- Well-formedness checking is not XSD/DTD validation or namespace-binding validation. XML 1.0 is supported; HTML and XML fragments with multiple roots are not.
- The limit is 5,000,000 input characters, 100 nested element levels and 100,000 nodes. Output is never silently truncated.
- Save exports UTF-8. Documents that declare a non-UTF-8 encoding must be decoded and have their encoding declaration updated before using this text tool.