XML Formatter & Validator
Format, validate and minify XML instantly — 100% in your browser.
About XML Formatter & Validator
Paste your XML below and it is instantly validated and pretty-printed with consistent indentation. If the XML is malformed, you get the parser's error message and the line it occurred on so you can fix it fast.
Validation uses the browser's native XML parser and the formatter preserves comments, CDATA sections, processing instructions and DOCTYPE declarations. Everything runs locally in your browser — your data is never sent to a server, which makes it safe for API payloads, config files and other sensitive documents.
How to use XML Formatter
- Paste a whole XML document, including its root element. Load the sample if you want to compare indentation first.
- Choose indentation or Minify, then check validation before copying the output.
Limitations and common mistakes
A document needs one root element, correctly nested tags and escaped ampersands. Whitespace inside text content can be significant; review mixed-content output.
Validation checks well-formed syntax, not whether the document satisfies an XSD, DTD or an application-specific schema.
The tool processes its input locally on your device. Read our privacy policy for analytics, storage and network details.
Format compact XML
<note><to>Tove</to><from>Jani</from><body>Reminder</body></note>
<note> <to>Tove</to> <from>Jani</from> <body>Reminder</body> </note>
Switch the indent selector to 2/4 spaces or tabs, or use Minify to strip whitespace.
Frequently asked questions
Is my XML uploaded to a server?
No. Validation and formatting happen entirely in your browser, so your data never leaves your device.
What does the validator check?
It uses the browser's native XML parser, so it flags any well-formedness errors — unclosed or mismatched tags, stray angle brackets, bad attribute quoting, and so on — with the message and line number.
Does it keep comments and CDATA?
Yes. Comments, CDATA sections, processing instructions and DOCTYPE declarations are preserved; only insignificant whitespace between elements is reflowed.
Can it minify XML too?
Yes. The Minify option removes whitespace between elements to produce a single compact line of valid XML.
For related tasks, explore XML ⇄ JSON and XPath Tester. Their guides explain the different inputs, assumptions and output formats.