About the XML Formatter tool
XML from SOAP services, RSS feeds, sitemaps, Android layouts and bank or GST e-invoice exports usually arrives as one dense line, which is painful to read and debug. This XML formatter re-indents the document so every element sits on its own line at the right depth, while short elements that only contain text, like <price>499</price>, stay on a single line for easy scanning.
Before formatting, the input is checked with the XMLValidator from fast-xml-parser. If a tag is not closed, an attribute is missing its quotes or elements are wrongly nested, you get the validator’s message with the exact line and column instead of a broken result. Comments, CDATA sections, processing instructions and the XML declaration are preserved as they are. Switch the mode to Minify to remove the whitespace between tags and produce the most compact version, with the option to keep or remove comments.
The tool runs entirely in your browser, so configuration files, invoices and API payloads containing personal data are never uploaded. Formatting also updates live, so you see the effect of every fix you make.
How to use XML Formatter
- Paste XML into the “XML input” box, click “Open file” to load an .xml file, or click “Load sample”.
- Choose the Mode: “Format / beautify” or “Minify”.
- For formatting, pick the Indentation (2 spaces, 4 spaces or tab). For minifying, choose whether to keep comments.
- If the XML is not well-formed, read the error with its line and column and fix the input.
- Click “Copy” or “Download” to save the formatted or minified file.
Features
Validation with line numbers
Checks well-formedness with fast-xml-parser, plus a check for more than one root element, and points to the line and column of errors.
Readable formatting
Indents nested elements while keeping text-only elements on one line.
Minify mode
Removes whitespace between tags, with an option to strip or keep comments.
Preserves special sections
CDATA, comments, DOCTYPE and processing instructions are kept intact.
Attribute values untouched
Whitespace inside quoted attribute values is never changed.
When to use it
- Read a SOAP request or response while debugging an integration.
- Check a sitemap.xml or RSS feed for unclosed or misnested tags.
- Tidy Android layout, Maven pom.xml or .csproj files before committing.
- Inspect e-invoice or bank statement XML exports.
- Minify XML before embedding it in a request or config value.
Frequently asked questions
Does the formatter check if my XML is valid?
It checks that the XML is well-formed: tags closed and nested correctly, attributes quoted, one root element. It does not validate against an XSD or DTD schema.
Will formatting change my data?
Element names, attributes and values are kept. Leading and trailing whitespace around text is trimmed, and in mixed content (text and child elements together) the text is placed on its own line, so avoid formatting documents where that whitespace is meaningful.
What does Minify remove?
It removes whitespace-only text between tags and, unless “Keep comments” is on, all comments. Text inside elements and CDATA is kept.
Can I format SVG or HTML with this tool?
SVG is XML, so it works. HTML is usually not well-formed XML, so use the HTML Formatter instead.
Is my XML uploaded?
No. Validation and formatting run entirely in your browser.
Why do I get an error about an unexpected closing tag?
A closing tag does not match the most recently opened element, usually because a tag was left open earlier. The error names both tags and the line where the mismatch was found.