Skip to content
AllToolsDesk

Popular

  • JSON Formatter & ValidatorFormat, minify and validate JSON with error locations.
  • CSS FormatterBeautify CSS, SCSS and Less with Prettier.
  • CSS MinifierCompress CSS and see the bytes saved.
  • JavaScript FormatterBeautify JavaScript and TypeScript.
  • JavaScript MinifierMinify JavaScript with Terser.
  • HTML FormatterIndent HTML, including inline CSS and JS.
  • JPG to PDFTurn images into a PDF, one per page.
  • Merge PDFCombine several PDFs into one file.
38 free toolsSee all tools

XML Formatter & Validator

Format, minify and check XML in your browser. Mismatched tags, unquoted attributes and unescaped characters are reported with line and column.

Runs in your browser. Nothing is uploaded.

Ready.

About the XML Formatter & Validator

XML is still behind many everyday files and integrations: RSS and Atom feeds, sitemaps, SVG images, Office documents, Android layouts, SOAP APIs and countless configuration formats. Unlike HTML, XML must be well-formed, so a single unescaped ampersand or mismatched tag makes the whole document unreadable to a parser.

Formatting indents the element tree so you can read it, and the checker reports the first well-formedness error with its line and column. Minify removes whitespace between tags for compact storage or transmission, while keeping text content as written.

How to use the XML Formatter & Validator

  1. 1

    Paste your XML, open a file (.xml, .svg, .rss and more), or load the sample. Pasting, opening a file or loading the sample runs it automatically.

  2. 2

    Choose an indent size.

  3. 3

    Press Format to indent it, Minify to remove whitespace between tags, or Validate to check it without changing the output.

  4. 4

    If the XML is not well-formed, the error shows the line and column. Fix it and run again.

Examples

1Indent nested elements
Before
<order id="7"><item sku="A1">Pen</item><item sku="B2">Paper</item><note/></order>
After
<order id="7">
  <item sku="A1">Pen</item>
  <item sku="B2">Paper</item>
  <note/>
</order>
2Mismatched closing tag
Before
<order><item>Pen</order>
After
Error on line 1, column 18: expected </item> but found </order>.

Good to know

  • This checks that XML is well-formed: balanced tags, one root element, quoted and unique attributes, escaped “<” and “&”. It does not validate against a DTD or XML Schema (XSD).
  • Formatting trims whitespace at the start and end of text, and puts text in mixed content (text next to child elements) on its own line. If spacing inside text matters, use Minify, which keeps text exactly as written.
  • Attributes stay on the same line as their tag.

Frequently asked questions

Can I format SVG or RSS files?

Yes. SVG, RSS, Atom and plist files are XML, so they can be formatted and checked here.

Why is “&” reported as an error?

In XML a bare “&” starts an entity such as &amp; or &#169;. Write &amp; for a literal ampersand, or wrap the text in a CDATA section.

Is my code uploaded to a server?

No. Processing happens entirely in your browser, in a background thread. Your input is never sent to our servers or stored anywhere.

More tools that pair well with this one.

Browse all tools