XML Formatter
Indent XML so it reads cleanly, and get told straight away if a tag is unclosed.
Your result will appear hereThis checks that tags are closed and nested correctly (well-formedness). It does not validate against a DTD or XML Schema.
Processed entirely in your browser — nothing is sent to a server.
About this tool
The XML formatter indents an XML document so its structure is visible, and tells you immediately if a tag is unclosed — naming the line where the problem starts.
XML is still everywhere in real work: RSS feeds, sitemap.xml, SVG files and the SOAP APIs many enterprise systems still expose. Those usually arrive as a single unbroken line, which is close to unreadable without formatting.
Two details get special attention. First, short elements stay on one line — <price>390</price> rather than three lines — because exploding every leaf doubles the document's length without making it any clearer.
Second, comments and CDATA are read as single units even when they contain a > inside, which is exactly where a naive formatter cuts in the wrong place and silently drops content.
Note the scope: this checks well-formedness, not validity against a DTD or XML Schema.
How to use
- 1Paste your XML into the input box
- 2It checks that every tag is closed and nested correctly, naming the line if something is wrong
- 3Choose the indent width you want
- 4Switch to collapse mode to get the XML back on one line, or copy the result
Frequently asked questions
- What exactly does it check?
- That every tag opens and closes in the right order — well-formedness. It does not validate against a DTD or an XML Schema that a receiving system might require.
- Why do short elements stay on one line?
- On purpose. Splitting <name>Somchai</name> across three lines makes the document much longer and harder to read, which defeats the point of formatting it.
- Are CDATA sections and comments handled?
- Yes. Both are kept whole even when they contain a > character inside them — precisely where a naive formatter cuts in the wrong place and loses content.
- Does it work with RSS, SVG or sitemap.xml?
- Yes. All three are standard XML, so they format and structure-check like anything else.
- Is my data uploaded?
- No. Both the check and the formatting run entirely in your browser.