tool
XML Formatter, Validator & Minifier
Pretty print XML, SVG, RSS and sitemaps, check that they're well-formed and minify them for production.
paste your code and choose format or minify
Pretty print, validate and minify XML
Paste any XML document, including API responses, SOAP envelopes, RSS and Atom feeds, sitemap.xml files, SVG icons, Android layouts, Maven pom.xml files or app configs, and turn it into neatly indented, readable XML. The validator uses your browser's own XML parser to confirm the document is well-formed and points to the exact line and column of the first error. Minify removes indentation and comments for a compact version. Entities, CDATA sections, comments and the DOCTYPE are kept exactly as you wrote them.
What can you do?
- 1. Pretty print XML
Each child element goes on its own line with two-space indentation, and attributes are tidied onto the start tag with single spaces. - 2. Check well-formedness
Find mismatched or unclosed tags, unquoted attributes, undefined entities like and multiple root elements, with messages such as “Line 3, column 21: Opening and ending tag mismatch”. - 3. Minify XML
Remove the whitespace between elements and all comments to make feeds, payloads and SVG files smaller. - 4. Nothing is rewritten
Entity references (&, ©), CDATA sections, processing instructions, the XML declaration and DOCTYPE internal subsets are copied exactly instead of being re-encoded. - 5. Text content is respected
Elements that contain text, such as <p>Hello <b>world</b></p>, are kept exactly as written, and xml:space="preserve" is honoured, so meaningful whitespace never changes.
Why pretty print and validate XML?
XML is usually produced by machines, and machines don't indent. A SOAP response, an exported config or a sitemap generated by a plugin often arrives as one enormous line, which makes it nearly impossible to find the element you're looking for or spot a missing value.
Unlike HTML, XML is strict: a single unclosed tag or an unescaped & makes the entire document unreadable for the program that consumes it. Search engines will reject a broken sitemap, feed readers won't load a broken RSS feed, and an API client will throw a parse error. Validating first finds the problem in seconds.
How to format XML online
- 1. Paste your XML
Paste the document, starting with the <?xml …?> declaration if it has one. Leading blank lines are ignored. - 2. Click format, minify or validate
The document is checked for well-formedness first, using the XML parser built into your browser. - 3. Fix any reported error
Go to the line and column in the message. Mismatched tags are reported where the parser noticed the mismatch, usually at the closing tag. - 4. Copy the result
Copy the formatted or minified XML back into your file or request.
Example: formatting a sitemap.xml
Common XML errors and how to fix them
| Error | Example | Fix |
|---|---|---|
| Mismatched closing tag | <from>Meena</form> | Make the closing tag match the opening tag exactly; XML is case-sensitive. |
| Unescaped ampersand | <title>Tips & tricks</title> | Write & as & (and < as <) in text and attributes. |
| HTML entity | <p> </p> | Use a numeric reference such as  , or declare the entity in a DTD. |
| Unquoted attribute | <item id=5/> | Quote every attribute value: id="5". |
| More than one root element | <a/><b/> | Wrap everything in a single root element. |
| Whitespace before the declaration | ⏎<?xml version="1.0"?> | The XML declaration must be the very first thing in the file. This tool trims leading blank lines for you. |
Well-formed vs valid XML
| Well-formed | Valid | |
|---|---|---|
| Meaning | Follows XML syntax rules | Well-formed and matches a DTD or XML Schema (XSD) |
| Checks | Tags, nesting, quoting, entities, one root element | Allowed elements, attributes, data types and order |
| Checked by this tool | Yes | No: use an XSD validator or your platform's tooling |
Frequently asked questions
Can I format SVG files?
Yes. SVG is XML, so you can pretty print an icon to edit it by hand, or minify it to remove indentation and editor comments before inlining it in HTML. The minifier doesn't remove editor metadata elements or simplify paths the way a dedicated SVG optimiser does.
Will formatting change my data?
No. Only the whitespace between elements that contain other elements is changed. Text content, attribute values, entities and CDATA are copied exactly.
Why is some content not indented?
Elements that contain text mixed with other elements, like <summary>Learn <b>XML</b> fast</summary>, are kept on one line exactly as written, because adding line breaks inside text would change the content.
Does minifying remove whitespace inside text?
No. Spaces inside text such as <b> hello </b> are kept, and so is everything inside elements marked xml:space="preserve". Only indentation between elements and comments are removed.
Can it validate against an XSD or DTD?
No. It checks that the XML is well-formed. Schema validation needs the schema files and is better done with your IDE or tools like xmllint.
Is my XML uploaded?
No. Parsing uses your browser's built-in XML parser, and formatting happens locally on your device.
Related tools
Working with HTML rather than XML? The HTML formatter understands HTML's more forgiving rules. Converting a data feed? Try the JSON formatter.
- HTML Formatter, Validator & Minifier – Indent markup, catch structural errors and compact HTML.
- JSON Formatter & Validator – Pretty-print, validate and minify JSON.
- YAML Formatter & Validator – Fix YAML indentation and find syntax errors in config files.
- Diff Checker – Compare two versions of text or code line by line.