XML Diff
Compare two XML documents structurally, ignoring attribute order and whitespace, and highlight every change.
What is XML Diff?
A structural comparison of two XML documents. Text diffing compares bytes; this compares trees, so re-indentation and reordered attributes produce no findings, and an inserted record is one change rather than a cascade.
How it works
Both documents are parsed, then walked in parallel. Children are matched by name first, and repeated records are matched by a key attribute or child when one exists, so an insertion does not make every subsequent record look changed. Added and removed elements, changed text, and added, removed or changed attributes are each reported with the path involved; the summary counts them by kind.
- Paste the document. Drop in XML, a schema, a feed or an XPath expression. Everything is parsed in the page: no upload, no server round trip, and the tools keep working with the network switched off.
- Set the options that match your document. Indent unit, whether to keep comments, which dialect, which output method. The defaults are the safe ones — nothing that changes meaning is enabled for you.
- Read the result, then copy or download it. Results appear as you type, copy straight to the clipboard, and download with a sensible filename (.xml, .xsd, .csv). Reset returns every field to its default.
Examples
A minified document from an API response
Paste one line of XML and the Formatter indents it, wraps long start tags one attribute per line and normalises empty elements — without touching text inside mixed content.
An XPath that works in Chrome and not in your servlet
The XPath Tester evaluates against a real tree and reports the axis or function it cannot support, instead of returning zero nodes and letting you guess why.
A document that will not parse
The Validator gives line and column for every mismatched tag, stray ampersand and duplicate attribute, with the reason in words: which open element was expected, which was found.
A schema that only half matches your data
The XSD Validator marks each violation with the path of the offending node, and the Schema Generator goes the other way — inferring a starting-point XSD from real documents.
Common mistakes
Assuming a pretty-printer cannot change meaning
Whitespace between elements is often insignificant, but inside mixed content it is not: `<p>Hello <b>world</b></p>` must stay on one line. Formatting here re-indents element-only content and leaves mixed content alone.
Treating a validation pass as proof of interoperability
The DTD and XSD validators implement honest subsets. A document reported valid here can still be rejected by a full validator that understands identity constraints, substitution groups or XSD 1.1 assertions — each page lists what it does not cover.
Reading the whole document because the parser did
A DOCTYPE is not inert. If your parser resolves external entities, pasting an untrusted document is enough to read a file or call an internal URL. The XXE Risk Checker shows what a document asks for; the fix is in the parser configuration.
Forgetting that attributes and elements are not interchangeable
`<id>1</id>` and `id="1"` mean different things to every schema and every XPath. When converting to CSV or YAML the distinction is preserved (`@id`), because flattening it away is the change that costs an afternoon later.
Frequently asked questions
Why does the diff show nothing for a file I reformatted?
Because nothing changed. Whitespace between elements is insignificant in XML and attribute order carries no meaning, so a document that was only pretty-printed is the same document. That is the point of a structural diff — and the Formatter's output is the reason it is needed.
How are repeated records matched?
By a key attribute such as `id` or `guid` when both sides have one; otherwise by position. With a key, inserting a record at the top changes one line instead of shifting every comparison below it, which is what makes the diff readable on real data.
Does it produce a patch I can apply?
No — it is a report, not a merge tool. For a patch, the Git Diff & Patch Viewer reads unified diffs; for combining documents, the XML Merge tool wraps them under one root. A three-way XML merge with conflict resolution is a genuinely harder problem and is not what this does.