Type a tool name, for example "keyword density" or "transcript".
Format XML in your browser while preserving mixed content and significant whitespace.
XML Parse Error
This free XML formatter turns compressed or messy XML into clean, indented markup you can read and copy. Paste your XML, pick 2 spaces, 4 spaces or a tab, and the tool shows a formatted version, or a clear parse error if the XML is broken. It suits developers, testers and anyone debugging feeds or config files.
XML (Extensible Markup Language) is a W3C text format for storing and exchanging structured data as nested tags. You meet it in sitemaps, RSS feeds, SVG images, Android layouts, SOAP messages, build and config files, and Office documents. Unlike HTML, XML has no fixed tag set: you define your own element names.
Formatting, also called beautifying or pretty printing, adds line breaks and indentation so the nesting is visible at a glance. A well-formed document needs one root element, properly nested tags, matching closing tags (names are case-sensitive), quoted attribute values and escaped special characters, such as & for an ampersand. Formatting does not repair these problems, but it makes them much easier to spot.
You can format a document in under a minute by following these steps.
If you click the button with nothing pasted, the tool asks you to paste some XML first.
Suppose you paste this single line: <root><item id="1"><name>Apple</name><price>1.20</price></item><item id="2"><name>Banana</name><price>0.50</price></item></root>
With 2 Spaces selected, the output puts <root> at the left edge. Each <item> sits two spaces in, and the <name> and <price> lines sit four spaces in, each with its text value on the same line. Both items now line up, so you can see in one glance that every item has a name and a price.
Switch to 4 Spaces or Tab and click the button again to get the same structure with wider steps. The meaning of the data never changes, only the whitespace between tags.
The formatter only adds line breaks where doing so cannot alter your data. An element that contains only other elements is split across lines and indented. An element that contains text stays on one line, so <name>Apple</name> is never broken apart.
This matters for mixed content, such as a paragraph with inline tags: <p>Hello <b>world</b></p>. Adding line breaks inside it would insert extra spaces into the text, so the tool leaves it intact. The same rule applies to these cases:
xml:space="preserve" are left untouched.Serialize Safely checks your XML and writes it back out without reflowing it, keeping text and comments exactly as they are. Use it when you want a parse check but must not change the layout. It is a cautious compact option, not an aggressive minifier, so whitespace that belongs to your document stays. If your input includes an XML declaration or a DOCTYPE, the tool returns it exactly as you pasted it.
A successful run fills the Output panel with indented XML and confirms that the XML was formatted. That also tells you the input is well-formed, because the tool cannot format a document it fails to parse. A failed run shows the first line of the parser message in the XML Parse Error box.
| Problem | Typical cause | Fix |
|---|---|---|
| Mismatched tag | Closing name differs from opening name | Match spelling and capitalization |
| Unclosed element | A tag was never closed | Add the closing tag or self-close it |
| Bad character | Raw ampersand or less-than sign in text | Replace with the escaped entity |
| Extra content | Two root elements side by side | Wrap everything in one root |
| Attribute error | Unquoted attribute value | Put the value in quotes |
The reported message usually names a line and column. Go to that spot first, but remember the real mistake is often a few lines earlier, where a tag was opened and never closed.
Anyone who reads XML written for machines will benefit, because machine output is usually one long line. These are common situations:
Two spaces keeps deeply nested files narrow, four spaces is easier to scan, and tabs let each reader set the width in their own editor. Match what your team or existing files already use, so version control diffs stay small.
If you include <?xml version="1.0" encoding="UTF-8"?>, it must be the first thing in the input. A blank line or space before it makes the XML invalid, and a common cause of a surprising parse error.
Write & for an ampersand and < for a less-than sign in text. A single raw ampersand in a product name or URL query string is one of the most frequent reasons well-looking XML fails.
HTML allows unclosed tags such as line breaks and unquoted attributes, which XML does not. For web pages, use the HTML formatter instead.
Copy the formatted version into a new file and compare it with the original. Only whitespace between tags should differ.
This tool checks that XML is well-formed. It does not validate against an XSD or DTD, so it cannot tell you that a required element is missing or that a value has the wrong type. Documents that contain a DOCTYPE declaration are returned as you pasted them rather than reindented. Input is limited to 2 MB, so very large exports are better handled in a desktop editor.
For other languages, the code beautifier handles HTML, CSS and JavaScript, and the JSON formatter and validator covers JSON.
Paste your XML into the formatter above, choose an indentation style and click Format / Beautify to get readable, well-formed markup in seconds. You can find more utilities like it in the web developer tools collection.
Your report has been submitted. We will look into this issue.
A VPN changes your network exit. It does not guarantee anonymity.
Themes, plugins, code, video, audio, graphics & more from 90,000+ authors.
Web Development
Design & Media
Unlimited Access
Explore Envato MarketAdds indentation only between element-only nodes. Mixed text, CDATA and xml:space content are preserved. Safe serialization retains significant whitespace and comments; DTD-bearing XML is returned unchanged. Input is limited to 2 MB.
Implementation reviewed: 4 October 2026. Source documentation