Home / Tools / XML Formatter
Free tool · runs in your browser

XML Formatter

Indent XML so you can read it, or strip it to a single line to send. Well-formedness is checked as you type using the browser's own XML parser, so you get the real parse error rather than a guess.

How it works

Well-formed versus valid

These are different checks and the distinction matters. Well-formed means the syntax is correct: every tag closes, attributes are quoted, there is exactly one root element, and entities are escaped. Valid means the document also conforms to a schema — a DTD, XSD or RelaxNG — that says which elements may appear where.

This tool checks well-formedness, using your browser's built-in XML parser. It does not fetch or apply a schema, so it will not tell you that <book> is forbidden inside <author>.

What the formatter changes

Beautifying puts each element on its own line and indents by nesting depth. Minifying removes the whitespace between tags.

Note that in XML, whitespace between elements is not always insignificant — it depends on the schema and on xml:space. For configuration files and data documents reformatting is safe; for documents with mixed content (text and elements interleaved, as in XHTML) reformatting can change meaning. The tool preserves text inside elements rather than re-wrapping it, which avoids the worst of this.

The five predefined entities

XML predefines exactly five entities: &lt;, &gt;, &amp;, &quot; and &apos;. A bare & or < in text content makes a document not well-formed, which is the single most common XML error. HTML's much larger entity set — &nbsp; and the rest — is not available in XML unless a DTD declares it.

What people use it for

  • Reading a minified API response or a SOAP envelope that arrived as one long line.
  • Finding the syntax error in a config file a parser rejected without a useful message.
  • Comparing two XML documents — format both first so a line-based diff is meaningful.
  • Inspecting a build file — pom.xml, an MSBuild project, an Android manifest.
  • Checking an RSS or sitemap file before publishing it.

Nothing is uploaded. This tool runs entirely in JavaScript in your browser. Your input is never sent to a server, never logged and never stored, and no account is required. Once the page has loaded you can go offline and it still works — open your browser's network tab and watch if you'd like to confirm it.

Frequently asked questions

Does this validate XML against a schema?

No. It checks well-formedness — correct syntax, matched tags, a single root, escaped entities — using your browser's XML parser. It does not fetch or apply a DTD, XSD or RelaxNG schema, so it cannot tell you whether the structure is allowed.

Is it safe to reformat any XML?

For data and configuration documents, yes. For documents with mixed content, where text and elements interleave, whitespace between elements can be significant and reformatting may change meaning. This tool preserves text inside elements rather than re-wrapping it.

Why is my ampersand an error?

A bare & is not legal in XML text. It must be written as &amp;. The same applies to a bare < which must be &lt;. XML predefines only five entities, so HTML entities like &nbsp; are not available unless a DTD declares them.

Will it handle very large files?

It parses and formats in the browser, so multi-megabyte documents may be slow or may exhaust memory. For large files use xmllint --format locally.

Is my XML uploaded?

No. Parsing and formatting happen entirely in your browser. This tool runs entirely in your browser. Nothing is uploaded, which matters when the thing you are formatting is a production config or a payload with real data in it.

Tools that run where your code is

This page does its work in your browser because sending your data to a server to process it is a bad default. Catalase applies the same idea to AI coding: a free, open-source code editor that runs language models on your own machine through Ollama, with no account and no telemetry. Cloud models are there when you choose one, not by default.

Download Catalase freeWhat is Catalase?

Related tools

All 30 free developer tools →