XML Formatter
Format and indent XML code into a clean, readable structure directly in your browser.
This tool runs entirely in your browser. Your files are never uploaded to a server.
<catalog>
<book id="1">
<title>
Example
</title>
</book>
</catalog>What this formatter does
Splits XML-like input into tags, comments, processing instructions, CDATA sections, and text tokens, then places each token on its own indented line. Every opening tag that isn't self-closed increases the indent for what follows; the matching closing tag decreases it back.
How to use it
Paste XML markup, inspect the result that appears immediately, and copy it when ready. Reset empties the editor and does not restore the sample.
Formatting behavior
A self-closing tag like <node/> doesn't increase the indent level, but every other opening tag does — unlike the HTML formatter, this treats no tag names as implicitly void, since in XML any element can have children. Comments, <!DOCTYPE> declarations, processing instructions and CDATA sections are each kept on their own line as a single token.
Important limitation
This is a lightweight token formatter, not an XML parser or validator — it doesn't check that the document is well-formed, doesn't verify that every opening tag has a matching closing tag, doesn't resolve namespaces or entities, and doesn't validate against a DTD or XML Schema. Malformed XML can still produce output; it just won't necessarily be correct.
Safe review workflow
Validate the result with a proper XML parser, your target system, or an XML Schema/DTD before relying on it, especially for documents you didn't author yourself — a missing closing tag or unescaped character can pass through this formatter unnoticed.
Privacy
Processing happens locally in your browser. The pasted XML is not uploaded by this tool.
Frequently Asked Questions
- What does the XML Formatter do?
- Format and indent XML code into a clean, readable structure directly in your browser.
- Does this XML tool change program behavior?
- It only changes layout or removable whitespace. Review minified output before production use when code relies on unusual syntax.
- Is my code uploaded?
- Processing is local and your code is never uploaded.