XML Formatter
Indent XML properly, and be told when a tag is closed in the wrong place.
Runs in your browser — nothing you type is sent anywhere
Indentation
Formatted
The result appears here as you type. Nothing is sent anywhere — the work happens in this page.
Comments and CDATA sections are passed through untouched, since their contents are not markup. Tag names are checked as it goes, so a tag closed in the wrong order is reported rather than silently indented.
About the XML Formatter
XML that arrives from an API, a configuration file or an export is usually either one long line or indented by nothing in particular. Reindenting it by depth makes the structure visible, which is the only reason anyone opens an XML document by hand.
It also checks as it goes. Tag names are tracked on the way in, so a tag closed in the wrong order — <code><a><b></a></b></code> — is reported by name rather than indented happily into output that no parser will accept. That is the difference between a formatter that counts depth and one that understands the document.
Comments and CDATA sections are passed through exactly as written. The contents of a CDATA block are not markup, so reformatting them would change their meaning; several formatters get this wrong and quietly corrupt embedded scripts and SQL.
Short text content stays on the same line as its tags, so <code><name>Ada</name></code> remains one readable line rather than becoming three. An element whose text is split across lines reads worse than the input did, which defeats the purpose.
There is no dependency behind this — it is a small amount of code that runs in your browser. Nothing is uploaded, which matters for the configuration files and API responses that make up most XML people need to read.
How to use the XML Formatter
Paste your XML
A document, a fragment or an API response. A declaration at the top is fine.
Choose the indentation
Two spaces, four spaces or tabs.
Format it
If a tag is closed in the wrong order, you are told which one rather than getting invalid output.
Copy or download
Take it to the clipboard or save it as an .xml file.
Frequently asked questions
Does it check the XML as well as format it?
What happens to CDATA?
Why is short text kept on one line?
Does it work for HTML?
Is my XML uploaded?
You may also need
XML to JSON
Convert an XML document or API response into JSON you can work with.
HTML Formatter
Indent minified or messy HTML into something readable.
JSON Formatter
Format, validate and minify JSON — with the exact line and column of any error.
YAML to JSON
Convert YAML into JSON, with indentation errors reported by line.