Skip to content
XUtilHub

XML Formatter & Validator – Beautify or Minify XML

Format, validate and minify XML online. Pretty print with your choice of indentation, check for errors and remove comments.

  • Free, no sign-up
  • Runs in your browser, nothing uploaded
Input
Output

About the XML Formatter

Beautify XML with clean indentation or minify it to a single line, and check that it's well-formed. Works with RSS feeds, SVG, sitemaps, SOAP messages and config files.

Key features

  • Beautify or minify XML
  • Checks that XML is well-formed
  • Error messages with line and column
  • Keeps the XML declaration, CDATA and processing instructions
  • Option to remove comments
  • Works with RSS, SVG, sitemaps, SOAP and config files

Format and check XML

Paste XML from an API response, a config file, an RSS feed or a sitemap to indent it neatly, or minify it to save space. Errors such as mismatched tags are reported with their position.

Before and after

<catalog><book id="1"><title>XML Guide</title><price>44.95</price></book></catalog>

becomes

<catalog>
  <book id="1">
    <title>XML Guide</title>
    <price>44.95</price>
  </book>
</catalog>

Common XML errors

ErrorCause
Opening and ending tag mismatchA closing tag doesn't match the open element, e.g. <a><b></a>
Extra content at the end of the documentMore than one root element
Attributes construct errorAn attribute value isn't quoted
EntityRef: expecting ';'A bare & in text; write &amp; instead

JSON to XML, sitemap generator, and YAML validator.

How to use the XML Formatter

  1. Paste your code into the input box, upload a file, or click Sample to try it out.
  2. Choose the options you want, such as indentation, line width or dialect.
  3. The result appears instantly in the output panel. Syntax errors are shown with their line and column.
  4. Click Copy to copy the result, or Download to save it as a file.

Frequently asked questions

What does well-formed XML mean?

Every opening tag has a matching closing tag, elements are properly nested, attribute values are quoted and there's a single root element. Malformed XML is rejected by XML parsers.

Does it validate against a schema (XSD or DTD)?

No. It checks that the XML is well-formed, which catches most errors, but it doesn't check the document against a schema.

Is whitespace inside elements preserved?

Leading and trailing whitespace in text is trimmed so elements can be indented. If whitespace inside a value matters (for example in xml:space="preserve" content), check the result.

Can I format an SVG file?

Yes. SVG is XML, so you can upload or paste it to format or minify it.

Is my code uploaded anywhere?

No. Every developer tool runs entirely in your browser, so source code, configuration files and passwords never leave your device.

Which formatter do you use?

HTML, CSS and JavaScript are formatted with Prettier, the most widely used code formatter, so the output matches what most projects use. SQL uses sql-formatter, and minification uses Terser and CSSO.

Is there a size limit?

There's no fixed limit. Very large files (several megabytes) can take a few seconds, depending on your device.

Last updated:

Related Dev tools