XML Formatter & Beautifier

Paste an XML document to format it with proper indentation, or minify it to one line.

Features

Beautify / minify toggle
Syntax highlighting
Attribute line wrapping

How to Use

1. Paste your XML into the input box.

2. Click Format to beautify, or Minify to compress.

3. Copy the formatted output.

About this tool

XML still powers RSS feeds, sitemaps, SOAP APIs, Office documents, Android layouts and countless configuration files, and it is almost unreadable without indentation. This formatter first checks that the document is well-formed with the browser's XML parser — every tag closed, attributes quoted, a single root element — and reports the parser's error message if something is wrong. Valid documents are pretty-printed with each nested element on its own indented line, keeping declarations, comments and processing instructions. Minify removes the whitespace between tags for compact storage or transfer. Well-formedness is not the same as validity against a schema, so a document can format cleanly and still be rejected by an application that expects specific elements.

Frequently Asked Questions

What is the difference between well-formed and valid XML?
Well-formed XML follows the basic syntax rules: tags are properly nested and closed, attribute values are quoted, and there is one root element. Valid XML also matches a DTD or XML Schema that defines which elements and attributes are allowed.
Why does my XML fail to parse?
Common causes are an unescaped & or < in text (use &amp; and &lt;), mismatched tag names that differ in case, multiple root elements, or content before the <?xml ?> declaration. The error message points to the problem.
Does formatting change the meaning of my XML?
Adding whitespace between elements does not change element structure, but in mixed content — text and tags together — or when xml:space="preserve" is used, whitespace can be significant. Review such documents after formatting.
Can I format a sitemap or RSS feed?
Yes. Sitemaps, RSS and Atom feeds are ordinary XML documents. Formatting them makes it easy to check URLs, dates and entries before submitting a sitemap to Search Console.
Is the XML sent to a server?
No. Parsing and formatting happen in your browser. That makes it safe for internal configuration files, but very large documents may take a moment on slower devices.

Related Tools