XML Diff — Compare Two XML Files Online (Semantic & Private)
Paste or open two XML files to see every added, removed and changed element, attribute and text value. The comparison is structural — attribute order and indentation never count as changes — and nothing leaves your browser.
What is XML Diff?
An XML diff compares two XML documents and identifies exactly what changed: elements added, removed, or modified, and attributes that changed value. Unlike a plain text diff, an XML diff understands document structure — it compares elements by tag name and path, not by line position, so reformatting the XML without changing its content produces no false differences. This free online XML diff tool highlights every change in green (added), red (removed), and amber (changed). Everything runs in your browser — no data is ever sent to any server.
When to Compare XML Documents
- SOAP API development — compare request/response envelopes before and after a service change
- Configuration management — audit XML config differences between environments (Spring, Maven, Ant)
- Android resources — compare layout or string resource files across branches
- Data migration — verify an XML transformation preserved all elements and attributes correctly
- RSS/Atom feeds — track changes in a feed over time
Before comparing, make sure both XML documents are valid using the XML Validator. To format XML for easier reading, use the XML Formatter. If you also work with JSON, our JSON formatter handles JSON the same way.
What counts as a change — and what doesn't
This tool parses both documents with the browser's XML parser and walks the two element trees side by side, so the report is about structure, not characters. Knowing exactly what is compared tells you what a clean identical result does and does not guarantee.
Counted as a change
- Elements added or removed — a tag present in one document and missing from the other, reported with its path, for example
library/book[2]/rating. - Attribute values — an attribute that appears, disappears or changes value, reported as
path/@name. - Text in leaf elements — the text inside an element with no child elements, compared after trimming leading and trailing whitespace.
- Order among same-named siblings — the second
<book>is compared with the second<book>. Reordering a list of identical tags therefore shows up as changed values, which is usually what you want for ordered data.
Ignored on purpose
- Attribute order —
<a x="1" y="2">and<a y="2" x="1">are the same element. Attributes are compared as a set of names and values. - Indentation and line breaks — whitespace between elements and around text values is not compared, so a minified file and its pretty-printed twin are identical.
- Comments, processing instructions and the XML declaration —
<!-- -->,<?xml-stylesheet ?>and the<?xml version="1.0"?>prologue are skipped. - CDATA wrapping —
<![CDATA[x]]>and a plainxcompare equal, because both are read as the text valuex.
Two things are compared literally: tag names, including any namespace prefix, so <ns:item>
and <item> are different elements; and text, so
1.0 and 1
are different values even if your schema treats them as the same number.
Comparing config files, SOAP payloads and sitemaps
Most XML diffs are not about two arbitrary files; they are about one file before and after something happened.
- Maven, Spring and Android configuration — paste the main-branch version as Source and your branch as Target. Because formatting is ignored, an IDE that re-indented the whole file produces no noise; only the dependency you bumped or the attribute you changed is listed.
- SOAP requests and responses — capture the envelope before and after a service change. The path output (
Envelope/Body/GetOrderResponse/Order/Status/text()) names the field that moved, without reading two hundred lines of namespace declarations. - Sitemaps and feeds — compare today's
sitemap.xmlor RSS feed with yesterday's to see which URLs or items were added or dropped. Same-tag ordering matters here, so a reshuffled feed shows every shifted item; sort both files first if you only care about membership. - Data migrations and transformations — run the original and the transformed document through the diff to confirm an XSLT or an export preserved every element and attribute it was supposed to.
XML diff from the command line
When the files live on a server or in CI, the same idea works in a shell. The trick is to normalise formatting first so a plain text diff stops reporting whitespace.
# Pretty-print both files, then diff the normalised output
xmllint --format a.xml > a.formatted.xml
xmllint --format b.xml > b.formatted.xml
diff a.formatted.xml b.formatted.xml
# Canonical XML also sorts attributes, so attribute order stops mattering
diff <(xmllint --c14n a.xml) <(xmllint --c14n b.xml)
# Python: a structural diff that reports edits as operations
pip install xmldiff
xmldiff a.xml b.xml
xmllint ships with libxml2 and is already installed on macOS and most Linux distributions.
The browser tool above does the normalisation for you and reports changes by path instead of by line, which is easier to read when the files are long.
Why compare XML in the browser
Many online XML diff tools send both documents to a server to compute the result. For a public sample that is fine; for a SOAP payload with customer data, a configuration file with connection strings, or an export from an internal system, it is a data transfer you did not need to make. This diff runs entirely in your browser using the built-in XML parser: the two documents are never transmitted, nothing is logged, and it keeps working if you go offline after the page has loaded. The Open file buttons read local files with the browser's FileReader API for the same reason — the file is read into the editor on your machine, not uploaded.
Frequently Asked Questions
What does XML Diff show?
It shows elements and attributes that were added (+), removed (−), or changed (~) between the source and target XML. Comparison is recursive — nested elements and their attributes are all checked.
Does formatting affect the diff?
No. This tool parses both documents into a DOM tree and compares structure and content — not text. Indentation differences, extra whitespace, or re-ordered attributes on the same element do not produce false differences.
What is the difference between an XML diff and a text diff?
A text diff compares line by line — reformatting or reindenting XML produces many false positives. An XML diff understands the document model, so it only flags meaningful structural or content changes.
Is my data safe?
Yes. All processing runs in your browser. Your XML documents are never sent to any server.
Does attribute order matter?
No. Attributes are compared by name and value, so <a x="1" y="2"> and <a y="2" x="1"> are reported as identical. Only an attribute that appears, disappears or changes value is listed.
Does whitespace or indentation count as a difference?
No. Whitespace between elements and around text values is ignored, so a minified file and a pretty-printed copy compare as identical. Whitespace inside a text value — a double space in a product name, say — does count, because it changes the value.
Can I upload XML files instead of pasting?
Yes. Use Open file on either panel, or drag a .xml file onto it. The file is read in your browser with the FileReader API — it is never uploaded.