Skip to content

XML formatter and validator

Format, beautify or minify XML and check it is well-formed, with errors explained by line and column and a tree view. Your XML is never uploaded or saved.

  • Runs in your browser
  • Nothing is uploaded
  • Free, no sign-up

Paste or open XML to check and format it. Nothing you add leaves this page.

How it works

The page reads your XML with its own parser, which follows the XML 1.0 standard and the rules for namespaces. When the XML isn't well-formed it stops at the first mistake and says which line and column, what is wrong and, for the common slips, how to fix it. Browsers word and place their own XML errors differently, which is why the page doesn't rely on them.

The XML beautifier puts each element that holds other elements on its own lines, indented one step per level; the spaces and line breaks between those elements are only layout, so they are replaced. An element that holds text keeps everything inside it exactly as written, because there spaces are part of the data, and so does anything under xml:space="preserve". Comments, <![CDATA[ ]]> sections, processing instructions, the DOCTYPE and references like &amp; are kept as you wrote them, and attributes keep their order and quotes; only the spaces inside tags are tidied. Minifying does the same without the line breaks.

As an XML viewer, the tree view lets you open and close each element, and pick one to copy its path (like /library/book[2]/price) or the element itself. Paths use the prefixes as written; an element in a default namespace, set with xmlns="…", needs a prefix bound to that namespace before an XPath tool finds it. Checking runs in a background worker inside this tab, so big files don't freeze the page. Spell checking is off in the box so the browser doesn't send what you paste off for checking.

Questions

How do I format XML?

Paste the XML into the box or open an .xml file. The page checks it as you type and shows it formatted, one element per line with the indent you pick (2 spaces, 4 spaces or tabs), or minified onto one line with “None (minify)”. Copy the result or download it. The tree view lets you open and close each element and copy its path.

Is it safe to paste XML with passwords or keys into an online XML formatter?

Only into one that doesn't upload it. In 2025 security researchers found tens of thousands of saved snippets, full of passwords and keys, on two popular code formatting sites, behind share links anyone could guess. Config files, SOAP messages and SAML responses often hold exactly those. This page checks and formats the XML in your browser: it is never sent to a server, saved, or put in the page address, and there is no save or share button that could leak it.

Does this XML validator check against an XSD schema or a DTD?

No. It checks that the XML is well-formed: every tag closed and correctly nested, one root element, attributes quoted, and every & written as a proper reference. That is what any program needs before it can read the file at all. Checking that the right elements are in the right places, against an XSD or DTD, is a separate step this page doesn't do, and it never downloads a DTD a file points to.

Why is my XML not valid?

The most common reasons are a bare & (write &amp;), an HTML entity like &nbsp; that XML doesn't know (write &#160;), a tag left open like <br> (write <br/>), end tags whose upper and lower case don't match the start tag, a second root element, and anything, even a blank line, before the <?xml?> declaration. The error message names which one it is, with the line and column.

Limits

Entities are never expanded and DTDs are never downloaded, so the page can't be tricked into reading other files or into building billions of characters from a few lines (the “billion laughs”). The other side of that: declarations inside the DOCTYPE are read only far enough to know which entities they declare, and what an entity stands for isn't checked. Entities from an external DTD are kept as written, with a note.

Files are read as UTF-8 or UTF-16, or in the encoding their <?xml encoding="…"?> declaration names. The result is always UTF-8, so a declaration that named another encoding is changed to say UTF-8, and the page tells you. Windows line breaks become plain ones, which XML programs read the same way.

The limit is 10,000,000 characters (about 10 MB) and 1,000 levels of nesting. Formatted text over 200,000 characters is shown without colours to keep the page quick, and the tree shows 100 nodes of an element at a time. XML 1.1 is checked by the rules of XML 1.0.

For JSON there is the JSON formatter, and text compare shows what changed between two versions of a file.

Privacy

This tool runs entirely in your browser. The files you open and what you type are never sent to a server, and nothing is stored after you close the page. See the privacy page.

Related tools