DevToolsmith

XML Diff

Compare XML by structure and values instead of formatting. Attribute order and namespace prefix changes do not create noise. Review changed paths and download the complete list of differences.

Runs 100% in your browser — nothing is uploaded

Original XML
Tip: drop a file here110 chars · 110 bytes · 4 lines
Changed XML
Tip: drop a file here133 chars · 133 bytes · 4 lines

Attributes are unordered; namespace prefixes are compared by namespace URI. Unchanged subtrees align child sequences; remaining edits are compared in order. Mixed text and xml:space="preserve" remain significant.

Compare meaning rather than formatting

XML allows different spellings for equivalent content. Attribute order is not significant, entity references are decoded, and a CDATA section can contain the same text as an ordinary text node. Namespace prefixes are aliases: the namespace URI and local name identify an element or attribute.

Equivalent XML names and values
<a:item xmlns:a="urn:shop" id="1" price="19.90">A &amp; B</a:item>
<!-- The following has the same expanded name, attributes and text. -->
<b:item xmlns:b="urn:shop" price="19.90" id="1"><![CDATA[A & B]]></b:item>

How paths and changes are reported

Paths use expanded names such as /{urn:shop}catalog/{urn:shop}item[1]/@price. The number identifies a child position. Identical subtrees align the sibling sequences so an inserted or removed node does not flag every later sibling as changed. Within unmatched sections, children are compared in order; identity is not guessed from ID attributes. Reordering remains significant. Removed and changed paths use original positions, while added paths use positions in the updated document. Downloaded JSON includes all differences, while the screen shows at most 300.

When to use a text diff instead

Use the text diff when comments, exact formatting or the original entity spelling matter. Use XML Formatter to check a document before comparing, or XPath Tester to inspect a particular subtree.

Frequently asked questions

Does attribute order count as a difference?

No. XML attributes are compared by expanded name and decoded value, so reordering them does not create a difference.

What if namespace prefixes change?

Prefixes are resolved to namespace URIs. Two elements using different prefixes for the same namespace compare as equal; changing the namespace URI is significant. Default namespaces apply to element names, not unprefixed attributes.

Which whitespace is ignored?

With the option enabled, whitespace-only indentation between element children is ignored. Whitespace in mixed text and inside xml:space="preserve" remains significant. CDATA and ordinary text with the same decoded content compare equally.

Are documents with DTDs supported?

No. Remove the DOCTYPE before comparing. External entities are never fetched. Each input is limited to 2 MB, 150 levels and 50,000 elements.