XML Formatter
Validate and indent XML locally, preserving mixed text content and rejecting entity declarations.
Loading tool…
How to use XML Formatter
Make element-based XML easier to read without executing its contents. For mixed content, CDATA sections, and elements marked xml:space="preserve", the formatter avoids adding indentation inside the element. XML parsing and serialization may normalize line endings and other representation details.
- Paste an XML document without a DTD or entity declaration.
- Choose indentation and format the document.
- Review and download the formatted XML.
Good to know
- DOCTYPE and custom entity declarations are rejected; external resources are never requested by this tool.
- Up to 100,000 input characters, 20,000 nodes, and 60 nesting levels.
- Browser XML serialization may normalize attribute quoting, empty tags, and namespace declarations. Downloads use UTF-8; any existing encoding declaration is updated to UTF-8 to match the file bytes.
Indent a small XML catalog without changing its text
Paste this catalog into Input, choose 2 spaces, and run the formatter. The two nested elements become easier to scan, while the title stays on one line because its text is meaningful content. Copy the result or download formatted.xml, then compare it with the source before replacing a file. This example needs the browser's XML parser; the formatted result below follows the current rendering logic. A document that parses successfully has passed a well-formedness check, not an application schema check. Keep any separately required XSD validation in your own workflow.
Input; choose 2 spaces for Indentation
<catalog><book id="1"><title>Small tools</title></book></catalog>
Expected formatted XML
<catalog>
<book id="1">
<title>Small tools</title>
</book>
</catalog>- Mixed text, CDATA, and xml:space=preserve receive special treatment so inserted indentation does not rewrite their internal content.
- Remove DOCTYPE and custom entity declarations before formatting; this tool refuses them rather than resolving external resources.
- Browser serialization can normalize quotes, empty tags, and namespace declarations. Do not use formatting as an original-byte preservation step.
Common questions
Does this validate an XSD?
No. It checks that the XML is well-formed; it does not validate a schema.
Why was a mixed-content element left on one line?
Inserting whitespace between text and child elements could change the content, so the formatter avoids adding indentation inside it. Parsing and serialization may still normalize line endings and other representation details.
Keep going with related tools
All developer →JSON to XML
Convert JSON into escaped, typed XML while preserving arbitrary object keys and array ordering.
DeveloperJSON Formatter
Format and indent valid JSON in your browser, with downloadable output and clear syntax errors.
SEOXML Sitemap Auditor
Inspect a pasted sitemap or sitemap index for namespace, URL, date and duplicate-entry issues offline.
DataXML to JSON
Convert XML into an ordered JSON element tree that retains attributes and mixed text content.
DeveloperJUnit XML Report Merger
Combine local legacy JUnit XML suites into one report ZIP while preserving every suite occurrence, original file and source-order evidence.
TextSelected SSML Source Auditor
Review a strict SSML 1.1 text/substitution/control profile with exact explicit pause totals, without generating audio or loading speech resources.