XML Diff Tool
Compare two XML documents and highlight differences
XML Document A (Left)
XML Document B (Right)
Diff Result
What is XML Diff Tool?
This tool compares two XML documents side by side and highlights the differences. It recursively walks both XML trees and identifies added elements, removed elements, and changed text content or attributes. Results are color-coded: green for additions, red for removals, and yellow for changes. For non-XML content like log files or plain prose, a general-purpose side-by-side text comparison tool is better suited — but XML needs a structure-aware diff because reformatting and attribute reordering would otherwise produce noisy line-by-line results.
Comparing XML 1.0 documents is a common task in software development — reviewing configuration changes, comparing API responses, auditing XML data exports, or verifying that an XML transformation produced the expected output. The diff uses the browser's native DOMParser API. All processing is client-side — your XML never leaves your device.
How to Compare XML Documents
Follow these steps to diff two XML documents.
Paste XML into Both Panels
Paste the first XML into the XML Document A panel and the second into XML Document B. Click Sample to load example documents.
Click Compare
Click the Compare button. The Diff Result panel lists every difference with its path, color-coded: green for added, red for removed, yellow for changed. Same-named siblings are matched by an id, key, name, code, sku or ref attribute when every one of them has a unique value, otherwise by content, so inserting one item near the top shows up as one addition rather than a cascade of changes.
Review and Copy
Review the highlighted differences. Click Copy to copy the diff summary to your clipboard.
When You'd Actually Use This
Config Change Review
Before deploying, compare the new XML config with the old one. Instantly see what changed, what was added, and what was removed.
API Response Auditing
Compare XML API responses from different environments (dev vs prod) or across API versions to verify consistency.
XML Transformation Verification
After applying an XSLT or other XML transformation, diff the input and output to verify the changes are correct.
Data Export Validation
Compare XML data exports from two different systems or time periods to find discrepancies in the data.
Frequently Asked Questions
Does my XML leave the browser?
No. The page reads both documents with the DOMParser built into your browser and runs the comparison locally.
What differences does the tool detect?
Added and removed elements, changed text (including CDATA), and added, removed or changed attribute values. A different root element name is reported too. Surrounding whitespace in text is ignored, and so is element order between differently named siblings.
How are repeated elements matched?
If every sibling with that name has a unique id, key, name, code, sku or ref attribute, they are matched by it, so reordering does not count as a change. Otherwise identical siblings are lined up first and the rest are compared in order.
Does it support XML namespaces?
Yes. Elements are compared by namespace URI and local name, as the XML Namespaces spec defines them, so a:item and b:item bound to the same URI count as the same element. Namespace declarations themselves are not reported.
Does it handle large XML documents?
Documents of a few hundred KB compare in a second or two. Very long lists of identical-looking siblings are compared position by position to keep it fast.
What if one of the XML documents is invalid?
The tool tells you which side failed to parse and does not compare. A blank line before the XML declaration is fine; it is stripped before parsing.
Related Tools
Explore other XML tools: