XML Formatter

Format and validate XML: indent it with 2 or 4 spaces or tabs, or minify it. Shows the error when XML is not well-formed. In your browser.

Runs in your browserNo sign-upWorks offline
Ctrl+Enter to run
Input121 characters
Output
✓ ReadySample content shown

What the XML Formatter does

The XML Formatter turns a single long line of XML into neatly indented, readable code, and checks that it is well-formed: every tag closed, attributes quoted and only one root element. Paste XML from an API response, a sitemap, an RSS feed, an Android layout or a config file. Choose 2 spaces, 4 spaces or tabs, or Minify to strip the spacing for sending. Comments, CDATA sections and the XML declaration are kept.

How to use it

  1. Paste XML on the left.
  2. Choose the indent, or Minify.
  3. Read the status: Well-formed XML, or the error and where it is.
  4. Copy or download the result.

Example

The sample book catalogue arrives as one line. Formatted with 2 spaces it becomes a tree of 8 elements, with each <book> on its own lines and the Hindi title गोदान kept exactly. Leaving out a closing </book> tag gives an error naming the tag that was not closed.

Well-formed is not the same as valid

Well-formed means the XML follows the basic rules, so any XML reader can open it. Valid means it also matches a schema (XSD or DTD) that lists which elements are allowed. This tool checks well-formedness, which catches the mistakes people make most often: missing closing tags, unescaped & characters and attributes without quotes.

Text inside elements is trimmed of spare spaces when formatting. If spacing matters, as in some document formats, keep the original.

Questions people ask

Is my code or data uploaded?

No. Everything runs in your browser, so config files, queries, logs and keys stay on your device. That makes it safe to use with work data.

Why does & cause an error?

In XML, & starts a code such as & or <. Write a plain ampersand as &.

Can it format HTML?

Use the HTML Formatter. HTML allows things XML does not, such as unclosed
tags.

Can I format a sitemap or RSS feed?

Yes. Both are XML, so paste the file to check it is well-formed and make it readable before submitting it.

Related tools