XML Formatter & Validator Logo
Developer Tools Embed Tool

XML Formatter & Validator

Format, validate, minify, copy, and download well-formed XML directly in the browser with readable indentation.

Format XML
0
Uses
—
Verified
Open
Access
Nov 2026
Added
Back to Directory

XML Formatter & Validator

Format, minify and validate XML with exact error locations, a collapsible tree, an XPath tester and document stats. Nothing leaves your browser.

Validator + XPath100% private
Ctrl + Enter to format
Options
Saved on this device 0

    Found a Bug or Missing a Feature?

    Report any problems or suggest new features you want. You can write in English, Urdu, Hindi, or any language! Our AI will analyze your feedback and upgrade the tool.

    About This Tool

    Format, validate, minify, copy, and download well-formed XML directly in the browser with readable indentation.


    XML Formatter and Validator: Fix Broken Sitemaps, Feeds and Config Files

    XML is quiet until it breaks. A sitemap stops being read, an RSS feed disappears from a reader, or an application refuses to start because of one stray character in a config file. The tool above formats XML so a human can read it, minifies it for transport, and tells you exactly where it is malformed, with the line, the column and a caret under the problem. It all runs in your browser, so internal configs and customer data stay on your machine.

    Well-formed is not the same as valid

    These two words get mixed up constantly. Well-formed means the document follows the basic grammar of XML: one root element, tags closed in the right order, attributes quoted, special characters escaped. Valid means it also follows a specific set of rules, written as a DTD or an XSD schema, such as "an order must contain at least one item". This page checks well-formedness, which is the first gate every parser applies. If a document fails here, no schema check will even begin.

    The five mistakes behind most errors

    1. Mismatched tags.<b><i>text</b></i> overlaps. Tags must close in the reverse order they opened. XML is also case-sensitive, so <Item> and <item> are different tags.
    2. A bare ampersand. A company called "Smith & Sons" must be written Smith &amp; Sons. The same goes for a less-than sign, which becomes &lt;. If you need help escaping text, the HTML Entity Encoder and Decoder does it quickly.
    3. More than one root. Two top-level elements side by side are not a document. Wrap them in a parent.
    4. Unquoted attribute values.id=1 must be id="1".
    5. HTML-only entities.&nbsp; exists in HTML but not in XML. Use &#160; instead.

    When validation fails, the message above the output is rewritten in plain language and shows the offending line with its neighbours. Press Jump to error to move the cursor there in the input box. Browsers word their parser errors differently, so the exact column may vary by a character or two.

    Formatting without damaging your data

    Pretty-printing adds whitespace, and in XML whitespace can matter. The formatter indents elements that contain only other elements, keeps simple text values on one line, and leaves mixed content (text with tags inside it, like a paragraph with bold words) exactly as written so sentences are not broken. Options let you sort attributes alphabetically for clean diffs, drop comments, trim padding around text, break long attribute lists across lines, and decide what happens to the XML declaration.

    Reading a large file: tree and stats

    The Tree tab shows the structure as collapsible nodes. Click a node to get its XPath, for example /rss/channel/item[2]/title, and copy it. The Stats tab counts elements, attributes, comments, CDATA sections, maximum depth, namespaces and the most used tags, which is a quick way to spot a feed that is bloated or a config with unexpected repetition.

    Testing XPath before you ship it

    Open the XPath tab, type an expression and see every matching node. Try //item/title on the RSS example, or count(//item) to get a number. Sitemaps trip people up because they declare a default namespace, which makes plain //loc return nothing. Use //*[local-name()='loc'] instead and all the URLs appear. Speaking of sitemaps: search engines generally accept up to 50,000 URLs and 50 MB uncompressed per file, so the node count in Stats is worth a glance.

    Moving between formats

    If the feed you were handed is actually JSON, use the JSON Formatter and Validator instead. To extract specific values from XML text with a pattern, the Regex Tester is a handy companion, though for structured data XPath is usually safer than regular expressions.

    Frequently asked questions

    Does this validate against an XSD or DTD?

    No. It checks that the XML is well-formed, which is what every parser requires first. Schema validation needs the schema file and a dedicated validator.

    Is my XML uploaded?

    No. Parsing happens in your browser. Nothing is sent to a server and external files are not fetched.

    Why does my sitemap XPath return nothing?

    Sitemaps use a default namespace. Match by local name, for example //*[local-name()="loc"].

    Will formatting change my data?

    Indentation only changes whitespace between elements. Mixed content is left as written, and text values are only trimmed if you leave Trim spaces on.

    What is the difference between Format and Minify?

    Format adds indentation and line breaks for reading. Minify removes the whitespace between elements to make the file smaller.