XML formatter

Pretty-print, check and minify XML.

Mode
Indent

0 lines · 0 characters

0 lines · 0 characters

Results update as you type.

Runs in your browser. Nothing uploaded.

How to format XML

  1. Paste your XML into XML.
  2. Choose Format and an indent to make it readable, or Minify to put it all on one line.
  3. If the XML isn't well-formed, the status line shows the line and what's wrong, such as a closing tag that doesn't match.

Well-formed vs. valid

XML has two levels of correct. Well-formed means the syntax is right: one root element, every tag closed and nested properly, attribute values in quotes and characters like & and < escaped in text. XML parsers refuse documents that aren’t well-formed. This tool checks the tags, attributes and characters before it formats anything, and stops at the first error.

Valid means the document also follows a schema that says which elements and attributes are allowed and in what order, such as a Maven POM schema or a sitemap schema. Checking that needs the schema file and a validating tool, like your IDE or xmllint.

Documents that mix text and tags

The formatter puts every child element on its own line. That is right for data and config files, but in documents where tags sit inside running text, like <p>Hello <b>world</b></p>, the new line breaks become part of the text. For HTML, use the HTML formatter, which keeps inline tags on the same line as their text.