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
- Paste your XML into the input editor, or click Load Sample.
- Choose the indentation size.
- Click Format / Beautify or Minify / Compress.
- 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
| Character | Escape as |
|---|---|
& | & |
< | < |
> | > |
" | " |
' | ' |
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
- XML to JSON — convert XML into JSON for modern apps.
- JSON to XML — the reverse conversion.
- HTML Formatter — beautify web page markup.