XML Formatter
Pretty-print and validate well-formed XML in your browser. CDATA, comments, and processing instructions preserved. No data leaves your device.
About this tool
Paste XML, click Format, and get indented output. Validation uses the browserβs DOMParser, which is fast and standards-based β it catches mismatched tags, bad character references, and malformed declarations.
This tool checks well-formedness only. Schema validation (XSD) and DTD-based validation are not performed. If your document conforms to a schema, use a dedicated validator for that; most modern editors and command-line tools handle that role better than a browser can.
The formatter handles CDATA sections, XML comments, processing instructions, and namespaced elements by treating them as opaque tokens during pretty-printing. That means attributes, namespace declarations, and escaped content round-trip unchanged.
Frequently asked questions
Is my XML sent to your servers?
No. Parsing and formatting happen entirely in your browser using the built-in DOMParser and a client-side formatter.
Does this validate against an XML Schema or DTD?
No. This tool checks well-formedness only β whether tags match and the document parses. Schema validation (XSD) and DTD validation are separate concerns, not supported here.
Are CDATA, comments, and namespaces preserved?
Yes. The formatter treats CDATA blocks, XML comments, processing instructions, and namespaced elements as opaque tokens and preserves them.
Why does my XML with leading text fail?
XML requires a single root element. Content before the root (outside of declarations and comments) makes the document not well-formed.
Can I format HTML with this?
No. HTML is not XML β use the HTML Beautifier tool (coming soon) for HTML.