Skip to content
GivenTool

Format, minify and check XML

Pretty-print or minify XML and check that it is well-formed, with the line and column of any error.

0 / 2,000,000 characters · Updates as you type.

Settings
Runs in your browser. Nothing you type is sent anywhere.

XML still runs a lot of the world: sitemaps and RSS feeds, SOAP and banking APIs, e-invoices, Android layouts, Office documents, SVG and countless configuration files. It usually arrives as one long line or with indentation that no longer matches the nesting. This formatter puts each element on its own line, indents children under their parent, keeps short text-only elements such as <title>Report</title> on one line, and leaves the XML declaration, comments, CDATA sections and doctype intact.

Before formatting, the document is checked for well-formedness: every start tag has a matching end tag in the right order, attribute values are quoted and not repeated, ampersands are written as entities, and there is exactly one root element. If anything is wrong you get a message such as "Expected </item> but found </list>" with the line and column, and the offending line shown with a caret, which is often faster than reading a stack trace from the program that rejected the file. The facts panel shows the root element, the number of elements and the deepest nesting.

Minify mode does the opposite: it removes whitespace between tags while keeping text content exactly as written, and can drop comments too. Note that well-formed is not the same as valid: this tool does not check a DTD or XML Schema, so a file can pass here and still be rejected by a system that expects particular elements. The formatter is a small purpose-built parser that runs in your browser; nothing is uploaded.

How to use it

  1. Paste the XML document into the input.
  2. Choose Pretty-print (and the indentation) or Minify.
  3. Fix any error using the line and column shown, then check the facts panel.
  4. Copy the result or download formatted.xml.

Frequently asked questions

Does it validate against a schema (XSD or DTD)?

No. It checks well-formedness, the rules every XML document must follow. Schema validation needs the schema file and a validating parser.

Will formatting change my data?

Pretty-printing adds indentation and trims whitespace at the start and end of text-only elements. If your format treats that whitespace as meaningful (rare, but possible with xml:space="preserve"), use Minify or keep the original.

Why is "&" an error?

In XML an ampersand starts an entity such as &amp; or &#169;. A bare & (for example in a URL query string) must be written as &amp;.

Are namespaces supported?

Yes. Prefixed names such as soap:Envelope and xmlns declarations are kept exactly as written.

Can I format a sitemap or RSS feed?

Yes, both are XML. To create a sitemap from a list of URLs, use the sitemap generator.