XML Formatter
Paste XML to see it neatly indented, or compacted into one line. Mistakes such as unclosed tags are reported with their position.
Use the tool
Loading the tool…
About XML Formatter
Paste XML and choose a layout: indented for reading, or compact for the smallest file. Choose 2 spaces, 4 spaces or a tab for indentation. The tool also checks that the XML is well formed, meaning its tags are correctly opened and closed.
Worked example
Paste a small XML document on one line and choose indented layout with 2 spaces. The output has each element on its own indented line.
Limits
A well-formed check does not confirm the XML matches the structure a system expects. Check that separately.
How to use XML Formatter
- Paste your XML.
- Choose an indented or compact layout.
- Choose the indent size.
- Copy the formatted XML.
Good to know
- A DOCTYPE (DTD) is refused on purpose, because it can load outside files or expand entities.
- Elements that mix text and tags, such as a paragraph with bold words, are copied exactly as written.
- Text, attributes, comments and CDATA are kept. Entities such as & are left as they are.
- Well-formed XML is not the same as valid XML, because no schema is checked.
Frequently asked questions
Does it validate against a schema?
No. It only checks that the XML is well formed.
Why is my DOCTYPE refused?
A DTD can pull in outside files or build huge texts from entities, so this tool does not process it. Remove the DOCTYPE and try again.
Is my XML saved or sent?
The work happens in your browser on this page, and nothing is stored or sent to us.