XML Diff & Compare
Compare XML structure, attributes and text spacing. Namespace URIs and child order are respected.
Worked example
The second document adds two whitespace text nodes. This XML comparison treats that spacing as significant.
XML Document A
<r><n>1</n></r>XML Document B
<r>
<n>1</n>
</r>Expected result
2 changes found · 0 changed · 2 added · 0 removedHow to compare XML
- Paste the original in Document A.
- Paste the modified in Document B.
- Click Compare XML.
What this XML diff compares
- Elements, attributes, text
- Namespaces
- Child order
- Comments, PIs, CDATA
What differences are ignored
- Attribute order
- Namespace-prefix renames
- Self-closing vs. explicit empty tags
When to compare XML versions
Comparing two versions of an XML document is useful whenever a file changes over time and you need to know exactly what moved. Common cases include reviewing edits to a configuration file before deploying it, checking that an API or SOAP request/response still matches an expected payload after a service update, and confirming what changed between two exports of an RSS or Atom feed.
Structural differences vs. rendered output
This tool compares the parsed document tree, not how two files happen to look side by side as plain text. Two documents can be byte-for-byte different yet structurally identical, or look nearly the same as text while differing in element order, attributes, or namespace bindings. Text whitespace remains part of the parsed structure: a space between child elements may be the space between words. This comparison reports it rather than assuming it can be removed.
Reading the diff results
Start by scanning for structural changes (added, removed, or reordered elements), since those usually matter most. Text and attribute value changes are typically lower risk but worth a quick check for typos or unit mismatches. If the result set looks larger than expected, check whether an early structural change has shifted how the rest of the document lines up.
Frequently asked questions
- What's the difference between a structural and a text difference?
- A structural difference is an added, removed, or reordered element or attribute. A text difference is a change to the value inside an existing element or attribute, with the surrounding structure unchanged.
- Will reformatting a file show up as a difference?
- Text whitespace is compared, so added indentation or changed line breaks can appear as differences. Attribute order, namespace-prefix renames with the same URI, and self-closing versus empty paired tags are ignored.
- Can I compare API or SOAP payloads that use namespace prefixes?
- Yes. Elements are matched by namespace URI and local name, so two payloads using different prefixes for the same namespace are still compared correctly.
- Does child order matter in the comparison?
- Yes. Sibling elements are compared in document order, so moving a child to a different position is reported as a change even if nothing else about it differs.
- Why does my diff show more changes than I expected?
- A single edit near the top of a large or deeply nested document can shift matching for everything after it. Comparing smaller sections, such as one feed entry or one config block at a time, usually narrows this down faster.