XML Formatter & Validator
Pretty-print, validate, or minify XML. Attributes, comments, and CDATA sections are preserved, and syntax errors are reported with the parser's diagnosis.
Mode
Frequently Asked Questions
- What does an XML formatter do?
- It takes raw or minified XML and re-indents it so the element hierarchy is easy to read, one element per line with your chosen indentation. It also validates the markup first — if the XML is not well-formed, you get an error describing the problem instead of broken output.
- How does XML validation work here?
- The tool parses your input with the browser's own strict XML parser (DOMParser). If parsing fails, the parser's error report — including the line number and the offending snippet where available — is shown so you can pinpoint the mistake, such as a mismatched tag or an unescaped ampersand.
- Are comments, CDATA sections, and attributes preserved?
- Yes. Formatting preserves element attributes, text content, comments, CDATA sections, and processing instructions. Only whitespace between elements is normalized to produce the indentation.
- What does minify do?
- Minify strips the whitespace between elements — indentation and line breaks that carry no meaning — producing the most compact single-line form of the document. Text inside elements is kept, so the document's content is unchanged.
- Is my XML uploaded to a server?
- No. Parsing, validating, formatting, and minifying all happen locally in your browser. Your markup never leaves your device.