How to use XML Formatter
- Paste XML or choose a local .xml file.
- Select indentation and preservation options, leaving text-sensitive whitespace intact when unsure.
- Resolve any validation error, then copy or download the parseable formatted document.
Supported behavior
XML Formatter validates an XML document before applying readable indentation. Choose two spaces, four spaces, or tabs, and decide whether to collapse empty elements, preserve the XML declaration, retain comments and CDATA, remove insignificant whitespace, or sort attributes. Text-node content, namespace prefixes, and namespace declarations are preserved, because changing them could alter meaning or interoperability. Parser errors include line and column when the available parser supplies them, and successful output remains parseable XML. External entities are never resolved; DTD and entity processing are disabled where supported, with protections against expansion attacks. Pasted markup and local .xml files stay in your browser and are never uploaded. Pretty-printing mixed-content XML is inherently sensitive: whitespace between text and child elements may be meaningful, so insignificant-whitespace removal defaults off. Attribute order is not semantically significant in XML, but leave sorting disabled when byte-for-byte presentation matters to another workflow.
- Removing insignificant whitespace can still be inappropriate for mixed-content documents.
- The tool does not validate against an XSD or fetch schemas, DTDs, or external entities.
Examples
<x:root xmlns:x="urn:demo"><x:item id="7">Ada</x:item></x:root>
Result: <x:root xmlns:x="urn:demo"> <x:item id="7">Ada</x:item> </x:root>
<?xml version="1.0"?><root><!--note--><empty></empty></root>
Result: <?xml version="1.0"?> <root> <!--note--> <empty/> </root>
Common use cases
- Indent a namespace-heavy configuration file for inspection.
- Validate an XML sample before including it in documentation.
- Normalize attribute presentation for a readable local comparison.
Frequently asked questions
Are namespace prefixes changed?
No. Prefixes and namespace declarations are preserved.
Will external entities be loaded?
No. External resolution is disabled and no network lookup is performed.
Can comments and CDATA remain?
Yes. Both have explicit preservation options.
Does formatting prove schema validity?
No. It proves the document parses as XML, not that it conforms to a particular XSD.

