XML Formatter
Indent XML, minify it or find the line and column of a syntax error.
Paste XML or open a file to format and check it.
Example · Mini book catalog
Large input preview. Paste again, open a file or clear the input to replace it.
Valid XML
<?xml version="1.0"?> <catalog> <book id="7">Trails</book> <book id="8">Maps</book> </catalog>
Showing the start of the result. Copy or download the full output.
The XML is ready with two-space indentation.
Processed on this device — nothing is uploaded
What you can do here
- Two or four spaces
- Minify XML indentation
- Line and column errors
- Preserve mixed content
- Copy or download XML
How do you make XML easier to read?
An XML formatter indents nested tags so you can see the document structure. Paste XML or open a local UTF-8 file, then choose two or four spaces, or Minify to remove line-break indentation between tags. The formatter keeps mixed content, CDATA and inherited xml:space settings. When markup is malformed, it reports a line and column and quotes the affected text.
Paste <catalog><book id="7">Trails</book><book id="8">Maps</book></catalog> and choose two spaces: each book lands on its own indented line under catalog. If a closing tag is missing, the message gives the line and column and names the tag it expected. Minify strips the line-break indentation again, ready to paste into a config file or API request. It checks that XML 1.0 is well-formed; it does not validate against an XSD or DTD.
Key facts
- Price
- Free
- Sign-up
- None
- Upload
- None — runs on your device
- Limits
- 8 MiB input and 512 levels of nesting · 24 million characters of output · Custom entity references are unsupported
- Works with
- Pasted XML 1.0 or a local UTF-8 XML file · Namespaces, CDATA and predefined or numeric entities
- Output
- Indented or compact XML · Syntax errors with line, column and nearby source
- Updated
How do you format and check XML?
- Paste or open
Paste XML, or open a local UTF-8 file up to 8 MiB.
- Pick the style
Choose 2 spaces, 4 spaces or Minify. The output updates straight away.
- Fix and save
If an error appears, jump to the reported line and column. Then copy the output or download it as an XML file.
Which whitespace does XML formatting preserve?
The formatter leaves text next to child elements, CDATA, single-line spaces and xml:space="preserve" regions alone. Indenting or minifying can change newline-based whitespace between elements. Check that indentation is optional in the format your document uses.
Frequently asked questions
How do I find a mismatched closing tag?
Read the reported line and column and look at the quoted source. The message names the closing tag expected at that point.
What does XML minification remove?
It removes line-break indentation around element-only content. It keeps mixed content, inline spaces, CDATA and whitespace under xml:space="preserve".
Can I format XML with a DOCTYPE or custom entities?
The formatter preserves one DOCTYPE before the root. It reads no DTD files and expands no DTD entities. Use predefined or numeric references such as & in the document.
Does opening a file upload my XML?
The XML checker reads the file on your device. Only standard page-use events are collected, without input, output or the filename.
Does this tool validate XML against a schema?
It checks whether XML 1.0 is well-formed. XSD, DTD and other schema validation are separate checks.
Related tools
About this tool
Made by ZirkoMirko. Last updated .
Check it yourself in your browser’s Network panel while using the tool. How we handle your data.
Sources
- W3C XML 1.0, Fifth Edition (checked )