# XML Formatter

Format XML into clean, consistently indented markup with the Prettier XML plugin. The tool first checks that the document is well formed, so mismatched tags, unclosed elements and unquoted attributes are reported with their line and column, then reflows it with your indentation, tab and line width settings. Built for developers tidying config files, feeds, sitemaps and API payloads.

## Frequently asked questions

### Which engine formats my XML?

The tool runs Prettier 3 with the official @prettier/plugin-xml plugin on the server. Before Prettier runs, a separate well-formedness check reads the whole document, so broken markup is rejected with a precise message instead of being silently rewritten.

### What does the well-formedness check catch?

It reports mismatched end tags, elements that are never closed, a second root element, text outside the root, duplicate or unquoted attributes, a raw < inside an attribute value and an & that does not start an entity reference. Each message names the line and column where the problem starts.

### What do the whitespace options mean?

Preserve, the default, keeps the meaningful whitespace inside text while still indenting elements. Ignore treats whitespace between elements as insignificant and may place inline text on its own lines. Strict never adds or removes whitespace that could change the document, which often leaves long lines with breaks inside tags.

### Can I choose the indentation?

Yes. Choose 2 or 4 spaces, or turn on tabs to indent with one tab per level. The print width, from 40 to 200 characters with 80 as the default, decides when attributes and children wrap onto separate lines.

### Are comments, CDATA sections and processing instructions kept?

Yes. Comments, CDATA sections, processing instructions such as stylesheet links and the DOCTYPE declaration all stay in the output. The XML declaration is kept as the first line.

### Does the formatter validate against a schema or DTD?

No. It checks only that the document is well formed. It does not load DTDs, XSD schemas or external entities, and entity references stay exactly as written.

### Will attribute order or quotes change?

No. Attributes keep their order, their values and the quote character you used. Only the spacing between attributes changes, and an attribute is never added or removed.

### How large can the input be?

The input can be up to 1 MB of text. Larger files are refused with a message so you can split them, and formatting stops after 10 seconds.

### Can I format SVG, RSS or sitemap files?

Yes. SVG, RSS, Atom, sitemaps, Android layouts, Maven POM files and other XML vocabularies are all XML, so they format the same way. To shrink SVG files instead, use the SVG Minifier.

### Is my XML stored?

No. The document is formatted in memory for your request and returned to the page. Nothing is written to disk and only the size of the request is recorded.

Your ad here?

[Email us](mailto:hi@dennn.is?subject=Advertising%20on%20OneClick%20Pro)

[Ad The agent-ready plugin suite for WordPress.](https://sleekwp.com/?ref=oneclickpro)
