XML Formatter & Minifier

Beautify messy XML code or minify it for production. Secure client-side processing with live validation.

Input XML
Formatted Result

What is XML?

XML (eXtensible Markup Language) is a text format for structured data that uses tags, much like HTML, except you define the tag names yourself. Although JSON has replaced it in many web APIs, XML is still everywhere: website sitemaps, RSS feeds, Android layouts, Microsoft Office files, SOAP web services, banking and government data exchanges, and countless configuration files.

This XML formatter turns compressed or messy XML into a cleanly indented document, checks that it is well-formed, and can minify it back into a compact single line.

How to Use the XML Formatter

  1. Paste your XML into the input editor, or click Load Sample.
  2. Choose the indentation size.
  3. Click Format / Beautify or Minify / Compress.
  4. If the XML has a syntax error, you’ll see an error message instead of output. Fix the problem and try again.

Before and After

<?xml version="1.0"?><order id="A102"><customer>Ravi</customer><items><item qty="2">Notebook</item><item qty="1">Pen</item></items></order>

Formatted:

<?xml version="1.0"?>
<order id="A102">
  <customer>Ravi</customer>
  <items>
    <item qty="2">Notebook</item>
    <item qty="1">Pen</item>
  </items>
</order>

XML Syntax Rules

  • There must be exactly one root element containing everything else.
  • Every element needs a closing tag (<name>…</name>) or must be self-closing (<br/>).
  • Tags are case-sensitive: <Item> and <item> are different.
  • Elements must be properly nested: <a><b></b></a>, never <a><b></a></b>.
  • Attribute values must be in quotes.
  • Special characters must be escaped.

Escaping Special Characters

CharacterEscape as
&&amp;
<&lt;
>&gt;
"&quot;
'&apos;

The unescaped ampersand is the most common cause of “XML parsing error” messages — for example a product name like “Salt & Pepper” or a URL with query parameters inside a sitemap.

Where You’ll Meet XML

  • sitemap.xml — tells search engines which pages your site has.
  • RSS and Atom feeds — used by blogs, news sites and podcasts.
  • Android apps — layouts and the app manifest.
  • Office documents — .docx and .xlsx files are zipped XML.
  • Enterprise and government APIs — SOAP services and many data-exchange standards.

Related Tools

Frequently Asked Questions

It indents XML so each nested element appears on its own line, revealing the document's hierarchy. It also checks that the XML is well-formed and reports errors.
Well-formed XML follows the basic syntax rules: one root element, every opening tag has a matching closing tag, elements are properly nested, attribute values are quoted and special characters are escaped.
Well-formed means the syntax is correct. Valid means it also follows a specific schema (DTD or XSD) that defines which elements and attributes are allowed. This tool checks well-formedness.
Escape them as &amp;, &lt; and &gt;. Alternatively, wrap the text in a CDATA section, which the parser treats as plain text.
Yes. Paste the sitemap XML to view it neatly indented and confirm that it is well-formed before submitting it to Google Search Console.
No. Parsing and formatting happen in your browser using its built-in XML parser.