Skip to content
cliplimeClipLime

Format and validate XML

Paste XML, get it indented and checked. Mismatched tags and bad entities are found by line and column, and nothing leaves this tab.

Your text is processed in this tab and never uploaded

Options

Turns <a></a> into <a/>. Both mean the same.

Applies to tags longer than 80 characters.

0 characters, 0 lines Your text stays in this tab.

Text and attribute values are copied exactly. Only the white space between elements changes, and elements that mix text with tags are left as written.

At a glance

What it does
Formats, minifies and checks XML as you type.
Indent
2 spaces, 4 spaces or tabs, with optional one attribute per line in long tags.
Checks
Matching tags, one root element, quoted attributes, entities, namespace prefixes, comments, CDATA and the XML declaration.
Kept as written
Text, attribute values, CDATA sections and comments. Only the white space between elements is rebuilt.
Mixed content
Elements that mix text with tags, or that ask to keep white space, are left as written.
Not checked
DTD and XSD schemas. Nothing is downloaded.
Privacy
Runs in your browser tab. Your XML is never uploaded.

How to do it

  1. 1

    Paste or load your XML

    Paste into the left box, drop an .xml file (or SVG, RSS, GPX and similar) on it, or press Example.

  2. 2

    Choose what to do

    Pick Format, Minify or Validate, then an indent and whether empty elements are written as <a/>.

  3. 3

    Read the result

    The result updates as you type. If the XML is not well-formed you get the line, the column, a likely cause and a Go to line button.

  4. 4

    Copy or download

    Copy the result or download it as a file.

What formatting changes, and what it never touches

In data style XML, the line breaks and indentation between elements carry no meaning, so a formatter can rebuild them. Everything else is copied exactly:

  • Text inside elements is never trimmed or re-wrapped. <name> Ann </name> keeps its spaces.
  • Attribute values, entity references such as &amp;, CDATA sections, comments, processing instructions and the DOCTYPE are copied as written.
  • An element that mixes text and child elements, such as <p>Hello <b>world</b></p>, is written back untouched, because the spaces around the tags are part of the text.
  • An element with xml:space="preserve" is written back untouched.

Small tidy-ups are applied to tags: one space between attributes, no spaces around =, and <a /> written as <a/>. The Write empty elements as <a/> option also turns <a></a> into <a/>. Both forms mean the same thing.

Common XML errors and what they mean

XML is far stricter than HTML. These are the problems people run into most:

  • Expected a closing tag, but found another. Tags must close in the reverse order they opened. The message names the tag that is still open and where it began.
  • Names are case sensitive. <Item> and </item> do not match.
  • This & does not start a valid entity. A literal ampersand must be written &amp;. It is common in URLs, such as ?a=1&amp;b=2.
  • Unknown entity &nbsp;. XML defines only &amp; &lt; &gt; &quot; &apos;. Use the character itself or a number such as &#160;.
  • An attribute has no value, or its value is not in quotes. <input disabled> and <a href=x> are HTML habits. XML needs disabled="disabled" and href="x".
  • A namespace prefix is not declared. <a:item> needs xmlns:a="..." on it or on an element around it.
  • The XML declaration must be first. A blank line or space before <?xml is an error.
  • A second root element. An XML document has one root element that holds everything else.

XML, SVG and HTML

SVG, RSS and Atom feeds, GPX tracks, Android layouts, Maven pom.xml and many config files are XML, so they format here. HTML is not XML: it allows unclosed tags such as <br> and <li>, so use the HTML formatter for web pages. Pages written as strict XHTML are XML and work in both.

Minifying XML

Minify removes the white space between elements and, by default, comments. Text, mixed content and xml:space="preserve" sections are left as written, so the document means the same. It is useful for payloads and for storing XML in a field with a size limit. For files people edit, keep them formatted.

Questions people ask

Does it validate against an XSD or a DTD?

No. It checks that the XML is well-formed, which means it follows the syntax rules. Checking against a schema needs the schema file and a schema aware validator. If a DOCTYPE points to an external DTD, nothing is downloaded and the rules in it are not applied.

Why does &nbsp; fail?

&nbsp; is an HTML entity. XML itself knows only five named entities, so a parser without a DTD stops at it. Use &#160; for a non breaking space, or type the character.

Will formatting change my data?

Only the white space between elements, and only where an element has child elements and nothing else. If your format treats that white space as data, use xml:space="preserve" on the element, or check the result before you rely on it.

Does it understand namespaces?

It checks that every prefix you use is declared in scope, and it copies xmlns declarations as written. It does not look up what a namespace means.

Is my XML uploaded?

No. The checks and the formatting run in your browser tab. For documents up to 3 MB the browser's own XML parser is also asked for a second opinion, and that runs locally too.

How large a file can it handle?

Up to 1.5 million characters the result updates as you type. Larger text waits for the Format now button. The limit after that is your device's memory.