XML Formatter & Validator
Free XML formatter, validator and viewer. Pretty-print or minify XML, find errors by line and column, and browse it as a tree. Private, in your browser.
Paste XML (a sitemap, RSS feed, SOAP response, Android layout, SVG or config file) to re-indent it, compress it onto one line or browse it as a collapsible tree. The browser's own XML parser checks that it is well-formed and reports the first error with its line and column. Formatting uses the xml-formatter library and everything happens on your device.
Runs in your browser. The processing engine downloads once on first use, then the tool works offline. Your files never leave your device. Free, no sign-up.
Features
- Well-formedness check with line and column
- Pretty-print with 2, 4 or tab indentation
- Minify to a single line
- Optional comment removal
- Collapsible tree view with attributes
- Element count and nesting depth
How to use XML Formatter & Validator
- Paste XML or open a .xml file.
- Read the validation result: well-formed, or the first error with its line and column.
- Pick Format (with indent size), Minify or Tree.
- Copy or download the result.
Frequently asked questions
What is the difference between well-formed and valid XML?
Well-formed XML follows the basic syntax rules: one root element, every tag closed and properly nested, attribute values quoted and special characters escaped. Valid XML is also well-formed and additionally matches a schema such as a DTD or XSD. This tool checks well-formedness; it does not validate against a schema.
Why does my XML show "Extra content at the end of the document"?
XML must have exactly one root element. That error usually means there are two top-level elements, or stray text after the closing root tag. Wrap everything in a single parent element.
How do I put an & or < inside XML text?
Escape them as & and < (and >, ", ' where needed), or wrap the text in a CDATA section such as <![CDATA[ a < b & c ]]>. A bare & is the most common reason an XML file fails to parse.
Does formatting change my data?
Formatting only adds or removes whitespace between tags. Whitespace inside text content can matter in some formats (mixed content, xml:space="preserve"), so keep the original if exact text spacing is important.
Is my XML uploaded?
No. Parsing uses your browser's built-in DOMParser, and the formatter library is loaded once from a CDN; the XML itself never leaves your device.
Related tools
- JSON Formatter — Format, validate and minify JSON
- HTML Formatter — Beautify and tidy HTML markup
- Data Format Converter — Convert between CSV, JSON, YAML, XML and SQL
- SVG Optimiser — Minify SVG exports and convert them to PNG
- CSS Minifier & Beautifier — Minify CSS with CSSO or prettify it, with a bytes and gzip savings report