Skip to main content

XML Diff Comparator

Compare two XML documents and see exactly what changed — added/removed elements, attribute changes and text changes with an XPath-like path to each one, plus a unified line diff of the normalized markup. Runs entirely in your browser.

Input

Options

Output

Summary
MetricValue
No data yet
Structural diff
 
Unified diff (normalized markup)
 

Both documents re-serialized with 2-space indent first, so formatting differences don't create noise.

Was this helpful?

Guides

Paste two versions of an XML document — a config before and after a change, two API responses, two feed exports — and see exactly what's different. This free online XML diff comparator reports structural changes (added/removed elements, attribute and text changes) keyed by a path to where each one lives, plus a normalized unified diff you can copy into a patch file. Comparison happens as you type, with no upload and no sign-up.

How to use it

  1. Paste the original document into XML A and the modified one into XML B.
  2. Toggle Ignore whitespace differences (on by default) so reformatted-but-otherwise-identical documents don't report spurious text changes.
  3. Toggle Ignore comment nodes (on by default) — turn it off to have <!-- ... --> comments themselves included in the structural diff.
  4. Read the Summary for counts, the Structural diff for a path-by-path list of what changed, and the Unified diff for a line-level view of both documents after normalization.

The output updates automatically as you type.

How does the structural diff decide what changed?

It walks both documents together, pairing same-tag sibling elements in document order (the second <book> in A is compared against the second <book> in B, and so on) and reporting, at each level: attribute additions/removals/changes, a change to the element's own direct text, and any child element that has no same-tag counterpart on the other side (reported as added or removed, with a short snippet). Each entry is prefixed with + (added), - (removed) or ~ (changed) and a path like /library/book[2]/@genre — the [2] only appears when more than one sibling shares that tag name.

Why is there also a "unified diff" — isn't that the same information?

No — the two views answer different questions. The structural diff tells you what changed and where, independent of how either document happens to be formatted. The unified diff shows lines, which is what you'd paste into a patch file or a code review — but a raw line diff of the original text would be full of noise from indentation differences that mean nothing. So both documents are first re-serialized into a normalized, 2-space-indented form, and that normalized text is what gets diffed line-by-line.

Does attribute order matter?

No. Attributes are always compared as an unordered set — reordering id="1" status="shipped" to status="shipped" id="1" produces no diff entries, since XML itself assigns no meaning to attribute order.

What if one of my documents is invalid XML?

The comparator parses both documents' well-formedness independently and reports a clear error naming the specific problem for whichever one failed, without attempting to guess at a diff against broken markup.

Is my data private?

Completely. Parsing and diffing run entirely in your browser using a self-contained XML parser — neither document is ever sent to a server, logged, or stored.

Comparing plain text instead of XML?

Use the Text Compare tool for a word/character-level diff of arbitrary text, or Git Unified Diff Patch Generator for a general-purpose unified diff.

xmldiffcomparechangesdeveloper

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.