Skip to content
helpyself

XML Formatter

Local only — nothing is uploaded unless you save or share it.

An XML formatter that indents, minifies and checks a document in your browser.

  1. Paste your XML into the box — it is formatted as you type.
  2. Pick Format, Minify or Validate, and choose the indent you want.
  3. Copy the result, or download it as a file.

Share a link

Saves this to your files and gives you a web address anyone can open. It stops working on its own.

Link lasts
Save this tool

Keep XML Formatter handy

Bookmark it

About this tool

Paste XML and get it back readable. Use it to format xml you have been handed as one unbroken line, or as an xml viewer for something too dense to read. This XML formatter indents one node per line, keeps attributes where they were, and leaves the parts people usually lose in a round trip — comments, CDATA blocks, the declaration and any processing instructions all survive intact. Three modes share the box. Format is the xml beautifier and the xml pretty print mode both: it lays the document out with the indent you choose, spaces or tabs. Minify xml strips the whitespace between tags for a config file or a request body, without touching whitespace inside CDATA where it may be the content. Validate is the xml validator: it reports whether the tags nest and close, and names the line of the first that does not — which is the whole difficulty of a long document. One thing it deliberately does not claim: this checks that XML is well formed, not that it is valid against a schema. Nesting, matching tags and properly terminated constructs are what it knows. Whether your document satisfies a DTD or an XSD is a different question and a much larger tool. It is an xml formatter online in the literal sense only — the page is online, the work is not. Everything runs in this page, and you can indent xml the browser never sent anywhere. There is no upload, no account, and no size limit beyond what your browser can hold — which matters, because the documents most worth formatting tend to be the ones you would rather not paste into somebody else's server.

Frequently asked questions

Is my XML uploaded anywhere?

No. The formatter runs entirely in your browser — the document never leaves the page, and there is no server involved in the version you are using on screen. That is deliberate rather than incidental: the XML most worth formatting is usually a config file, an invoice or an API response, none of which should be pasted into an unknown server to add some line breaks.

What is the difference between well formed and valid?

Well formed means the syntax holds together: every tag closes, tags nest rather than overlap, attributes are quoted, and constructs like comments and CDATA are properly terminated. Valid means it also matches a schema — a DTD or XSD saying which elements may appear where, and what they may contain. This tool checks the first. A document can be perfectly well formed and still be nonsense to the system expecting it.

Will it keep my comments and CDATA?

Yes, both, and this is worth checking in any formatter you use. Comments are kept by default and can be dropped with a switch if you are minifying for production. CDATA blocks are passed through untouched, including whitespace inside them — a formatter that reindents the contents of a CDATA block has changed your data, not your formatting. The XML declaration, doctype and processing instructions are all preserved too.

Why does it say my tags do not match?

Because a closing tag names a different element from the one still open — the classic being tags that overlap rather than nest, like an element opened inside another and closed outside it. The message names the line of the first mismatch, which is usually a few lines after the real mistake: the tag that was never closed is the culprit, and the error surfaces where the next close arrives and finds the wrong thing waiting.

Can it handle a big file?

It handles whatever your browser can hold in memory, which in practice means multi-megabyte documents are fine and a very large export may be slow while you type. There is no server-side limit because there is no server. If you are formatting something enormous, the API is the better route — it takes the same options and does the work in one request rather than on every keystroke.

Help improve this tool

Found a bug, want a change, or need a tool we don't have?

/xml-formatter

↑↓ to move · Enter to open · Esc to close