Developer ToolsA little help for every day

Search by name or task, such as JSON or percentage.

Developer Tools

XML Formatter and Well-Formedness Checker

Check that XML is well-formed, with the line and column of any error, then indent it with spaces or tabs, minify it, tidy empty elements or remove comments.

View all tools
ResultUpdates as you type
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://example.com/</loc>
    <lastmod>2026-10-01</lastmod>
    <priority>1.0</priority>
  </url>
  <!-- blog post -->
  <url>
    <loc>https://example.com/blog?id=1&amp;lang=en</loc>
    <image/>
  </url>
</urlset>

Well-formed: 8 elements, nested up to 3 levels.

Checks well-formedness only (tag pairs, attribute quotes, entities), not XSD/DTD validity. Text-only elements stay on one line and surrounding whitespace in text is trimmed.

How to use XML Formatter and Well-Formedness Checker

Paste XML such as a sitemap, RSS feed or SOAP message. It is checked first: if it is well-formed you get indented output straight away, otherwise an error with its line and column. Options cover minifying, empty elements and comments.

  1. Paste the XMLPaste a document with a single root element; if there is an XML declaration it must come first.
  2. Choose the layoutPick Format and validate or Minify to one line, the indent, and whether empty elements are kept, self-closing or expanded.
  3. Fix and copyIf an error appears, go to the line and column shown, correct it, then copy the formatted XML.

Errors the checker catches

The parser checks that tags are properly nested and closed, attribute values are quoted, no attribute appears twice, & and < in text are written as &amp; and &lt;, there is exactly one root element with no stray text outside it, and the XML declaration sits at the very start. Every error gives a position: a bare & in Fish & chips, for example, is reported at line 1, column 9 with a reminder to write &amp;. Entities such as &nbsp; that XML does not predefine trigger a warning. The tool checks well-formedness only, not validity against an XSD or DTD.

How the output is formatted

Each element goes on its own line, indented by depth, while elements that contain only text stay on one line, so a sitemap loc element keeps its URL between the tags. Comments, CDATA sections, processing instructions and the DOCTYPE are kept, and attributes keep their order and quotes. Whitespace at the ends of text is trimmed and whitespace-only text nodes are dropped, so check content where spacing matters. Minify removes the line breaks and indentation between tags, and Remove comments strips comment blocks from either output.

Accuracy and data handling

Validate the result with your project's own tests and runtime rules before using it in production. The calculation runs in your current browser; the tool code does not send the input to a processing API.

Often Used Together

Next step

FAQ

Does it validate against an XSD or DTD?

No. It checks well-formedness: tag pairs, quoting, entities and a single root. Validating against a schema needs a validating parser together with the XSD or DTD.

What does Text is not allowed outside the root element mean?

There is ordinary text before or after the single root element, often a stray character from copying or two XML documents pasted together. Remove it or wrap everything in one root.

Will formatting change my data?

Tags, attributes and text content are kept, but leading and trailing whitespace inside text is trimmed. If spacing is significant, compare the output before you use it.

More Developer Tools

Related tools