XML Formatter

Format, beautify or minify XML with your choice of indentation — and see exactly where invalid XML breaks.

Options

Waiting for XML…

No uploads. Your files stay on your device.

Free forever, no sign-up, no cookies. Buy me a coffee

How it works

Paste XML into the top box and it is checked and re-indented instantly. The formatter first parses your document with the browser's own XML parser, so anything that is not well-formed — a mismatched closing tag, an unquoted attribute, a stray & — is reported with the exact line and column instead of being silently mangled. Well-formed XML is then rewritten with one node per line: elements are indented with 2 spaces, 4 spaces or a tab, attributes are normalised to a single space apart, and short elements such as <title>Hello</title> stay on one line so the result reads like hand-written XML. The declaration (<?xml … ?>), processing instructions, the DOCTYPE, comments and CDATA sections are all preserved; text content is trimmed and inner line breaks are kept.

Switch Output to Minify to collapse the whole document onto a single line — useful for SOAP envelopes, RSS feeds, sitemaps or config files you need to embed somewhere — and tick Remove comments to strip <!-- … --> blocks while you are at it. The counters show how many elements the document has, how deeply it nests, and how much smaller the minified version is. Everything runs as plain JavaScript in your browser: unlike most online XML formatters, your document is never uploaded to a server, which makes it safe for API payloads, invoices and anything confidential. Use Copy XML or Download .xml when you are done.

Frequently asked questions

How do I format XML online?

Paste your XML into the top box. It is parsed and re-indented as you type, so the formatted result appears instantly below — no button to press. Pick 2 spaces, 4 spaces or a tab for indentation, then use Copy XML or Download .xml to take the result with you.

Does this XML formatter validate my XML?

Yes. Every keystroke is checked with the browser's own XML parser first. If the document is not well-formed — a mismatched closing tag, an unquoted attribute value, an unescaped ampersand — you get the exact line and column of the problem instead of a mangled result, so it doubles as a quick XML validator.

Is my XML uploaded to a server?

No. The formatter is plain JavaScript running in your browser, so your document never leaves your device and nothing is logged or stored. That makes it safe for API payloads, SOAP envelopes, invoices and other confidential XML that you should not paste into an ad-supported online tool.

Report a bug