How to use
- Paste XML into the input | a sitemap.xml, an RSS feed, an Android layout, a Maven pom.xml, a SOAP response.
- Beautify puts each element on its own line with indentation. Elements that contain only text stay on one line, like
<title>News</title>. - Minify removes only the line breaks and indentation between tags. Text content is never touched.
- If the XML isn’t well-formed, you get the line and column of the problem with the spot highlighted, instead of a result.
Well-formedness rules
Checking uses your browser’s built-in XML parser (DOMParser), which follows the W3C XML 1.0 rules.
| Rule | Wrong | Right |
|---|---|---|
| Every element must be closed | <br> |
<br/> or <br></br> |
| Tag names are case-sensitive | <Item></item> |
<item></item> |
| Elements must nest, not overlap | <b><i>text</b></i> |
<b><i>text</i></b> |
| Exactly one root element | <a/><b/> |
<root><a/><b/></root> |
| Attribute values need quotes | <a id=1> |
<a id="1"> |
Escape & and < |
<q>A & B</q> |
<q>A & B</q> |
| Names can’t start with a digit | <1st/> |
<first/> |
A very common sitemap error is a URL like ?a=1&b=2 where the & wasn’t written as &.
Things to watch out for
- Beautify drops whitespace-only lines between tags and trims spaces around text. Add
xml:space="preserve"to any element where whitespace matters and its contents are kept exactly as written. - Entities (
&,<) and CDATA sections are kept as-is, never decoded, so your data doesn’t change. - This checks well-formedness only. It doesn’t validate against an XSD or DTD schema.
FAQ
Is my XML executed or uploaded?
No. The XML is parsed for checking only and never inserted into the page, and no external DTDs or resources are fetched. Nothing is sent to a server.
Can I format JSON or HTML too?
Use the JSON Formatter for JSON and the HTML Beautifier & Minifier for HTML. HTML allows unclosed tags like <br>, so it fails XML rules.