HTML Formatterhtmlformatteronline.com

XML formatter

Format XML, RSS feeds, sitemaps and SVG. The check names every unclosed or mismatched tag by line, including the case mismatches that catch people out.

Your XML 0 lines
Format
Formatted 0 lines
Paste XML on the left, then press the button.

XML is stricter than HTML, and that helps

HTML forgives a missing </li>. XML forgives nothing: every element must be closed, tag names are case-sensitive, and <Item> is a different element from <item>. That strictness means a well-formedness check on XML is genuinely conclusive.

This tool formats XML, RSS and Atom feeds, SVG files, XML sitemaps, SOAP envelopes, Android layouts, Maven POM files and configuration in any XML dialect. It preserves CDATA sections, processing instructions and namespace prefixes exactly.

What the check reports

  • Unclosed elements, named with the line they opened on.
  • Mismatched tags, including the case-only mismatches that cause most of the confusion for people arriving from HTML.
  • Stray closing tags with nothing open to close.

Self-closing tags keep their slash: <br/> stays <br/>, because in XML dropping it would turn the element into one that swallows the rest of the document.

Common uses

RSS and Atom feeds

Feeds are generated by templates and arrive on one line. Formatting is the quickest way to check that every <item> has the elements a reader needs.

XML sitemaps

Search Console rejects a sitemap on a single parse error and does not always say where. Format it, check it, then resubmit.

SVG files

Exported SVG is one long line full of editor metadata. Formatting it is the first step to trimming it down by hand.

API responses

SOAP and older REST services still return XML. Formatting an error response is often the only way to find the fault string buried in it.

Configuration files

Maven, Spring, Android manifests, .NET config. All XML, all easier to edit with real indentation.

Office documents

A .docx or .xlsx is a zip of XML files. Unzip one and format the parts to see how the document is actually built.

Well-formed is not the same as valid

These two words mean different things in XML and the distinction matters.

Well-formed means the syntax is correct: tags closed, correctly nested, one root element, attributes quoted. That is what this tool checks, and nothing can process your XML until it passes.

Valid means the document also conforms to a schema — a DTD, an XSD or a RELAX NG grammar — that says which elements may appear where, in what order, with which attributes. Checking that requires the schema, and this tool does not do it.

For RSS specifically, the W3C Feed Validation Service checks both syntax and feed-specific requirements, and is worth running before you publish a feed.

The five reserved characters

XML reserves five characters. Inside element text or an attribute value they must be escaped, or the parser will read them as markup:

CharacterEscape asRequired where
<&lt;Everywhere
&&amp;Everywhere
>&gt;Everywhere, by convention
"&quot;Inside double-quoted attribute values
'&apos;Inside single-quoted attribute values

The alternative is a CDATA section — <![CDATA[ ... ]]> — which tells the parser to take everything inside literally. That is how RSS feeds carry HTML inside a description. This tool leaves CDATA blocks completely untouched. The entity encoder will escape a block of text for you if you would rather not use CDATA.

Questions about this tool

Why does it complain that my tags do not match when they look identical?

Almost always case. XML is case-sensitive, so <Title> and </title> are different elements. HTML does not care, which is why people coming from HTML hit this constantly.

Can it format SVG?

Yes — SVG is XML. Self-closing tags are preserved, attributes and namespaces are untouched, and the result renders identically. It is the easiest way to make an exported SVG editable by hand.

Does it validate against my XSD or DTD?

No. That requires loading the schema and is a different class of tool. This checks well-formedness, which is the prerequisite — nothing can validate against a schema until the document parses.

What happens to my XML declaration and namespaces?

Both are preserved exactly. The <?xml ... ?> declaration stays on the first line, and namespace prefixes and xmlns attributes are passed through untouched.

Can I use it on an HTML file?

You can, but you will get a long list of complaints about unclosed <li>, <p> and <br> elements that are perfectly legal in HTML. Use the HTML formatter for HTML — it applies the right rules.

Related tools

Learn the why, not just the how

Longer reading on formatting, indentation and minification.