How to format XML
- Paste a simple, well-formed XML 1.0 document.
- Review the whitespace policy. Check it only when whitespace-only text between child elements represents indentation.
- Choose 2 spaces, 4 spaces, or tabs, then select Format XML. Review the output before copying or downloading it.
Supported example: <service><name>Search API</name><retry enabled="true"/></service>.
Supported content and limits
This formatter supports element hierarchies, attributes and namespaces, comments, empty elements, and single-line text-only leaves that contain visible text. It preserves decoded attribute values and supported leaf text, including leading or trailing spaces. Quote style, entity spelling, and empty-element spacing may be normalized.
Whitespace-only text leaves, mixed text and child elements, multiline text leaves, CDATA, processing instructions other than the XML declaration, and any xml:space attribute are reported as unsupported without changing your input. DOCTYPE, DTDs, and entity declarations are rejected before parsing. XML is checked for well-formed syntax, not validated against an XSD. XML 1.0 and UTF-8 are supported; a leading BOM is removed from the formatted output.
Whitespace and privacy
Whitespace between child elements may carry meaning in an XML application. The consent checkbox lets the formatter replace only whitespace-only text in those positions for indentation. Keep it unchecked if that whitespace is data. A whitespace-only leaf is rejected because the pinned library cannot preserve its exact value. Input is processed in this browser; XML is not uploaded, stored, or fetched from an external URL.
Why is mixed content unsupported?
Spacing around words and nested elements can be significant, so this tool keeps those documents unchanged.
Are DTDs or external entities loaded?
No. DOCTYPE declarations are rejected before XML parsing, and the tool does not fetch schemas, namespaces, or entities.
Does formatting validate an XSD?
No. It checks well-formed XML and preserves the supported subset only.