# 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.

- URL: https://tools.crawlink.com/xml-formatter
- Category: Developer Tools
- Price: Free, no account, no usage limits
- Privacy: Runs in your browser. The processing engine downloads once on first use, then the tool works offline. Your files never leave your device.

## What it does

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.

## 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

1. Paste XML or open a .xml file.
2. Read the validation result: well-formed, or the first error with its line and column.
3. Pick Format (with indent size), Minify or Tree.
4. Copy or download the result.

## FAQ

### 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 &amp; and &lt; (and &gt;, &quot;, &apos; 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.

Also searched as: xml formatter, xml beautifier, xml validator, xml viewer, xml pretty print, xml minify, format xml online.

## Related tools

- [JSON Formatter](https://tools.crawlink.com/json-formatter): Format, validate and minify JSON
- [HTML Formatter](https://tools.crawlink.com/html-formatter): Beautify and tidy HTML markup
- [Data Format Converter](https://tools.crawlink.com/data-converter): Convert between CSV, JSON, YAML, XML and SQL
- [SVG Optimiser](https://tools.crawlink.com/svg-optimizer): Minify SVG exports and convert them to PNG
- [CSS Minifier & Beautifier](https://tools.crawlink.com/css-minifier): Minify CSS with CSSO or prettify it, with a bytes and gzip savings report

---
Part of Tools by Crawlink — https://tools.crawlink.com/ · All tools: https://tools.crawlink.com/llms.txt
