textdiff

textdiff / XML compare

XML compare: diff two XML documents

Paste or open two XML files. Both are re-indented identically before comparing, so a one-line export and a nicely formatted file compare cleanly.

0 chars · 0 lines
0 chars · 0 lines

Why formatting first matters

The example above has the same catalog twice: once squashed onto one line, once indented. A raw diff would call the whole file changed. After both sides are parsed and pretty-printed with the same two-space indentation, only the three real changes remain: a new title, a new price and an added <genre> element.

Parsing uses your browser's built-in XML parser (DOMParser), so namespaces, CDATA sections and comments are kept. Untick Pretty-print to compare the files exactly as written. For HTML, the HTML compare is more forgiving of unclosed tags.

Questions

Does XML compare ignore formatting?

With "Pretty-print before comparing" on, both documents are parsed and re-indented the same way first, so differences in indentation, line breaks and whitespace between tags disappear and only real content changes remain.

Does the order of attributes matter?

In XML, attribute order has no meaning. The pretty-printer keeps attributes as written, so reorder them identically or compare with ignore whitespace; element order does matter and is compared.

What happens if my XML is not well-formed?

The parser error is shown and the raw text is compared instead, so you still see the differences and can spot the broken tag.

Can I compare SVG, RSS, sitemap.xml or .csproj files?

Yes, they are all XML. Open them as files or paste them.