How to compare two XML files online and get a clean diff

A practical guide to comparing XML in the browser: pretty-print, attribute order, namespaces, and when a line diff is the wrong tool.

15 Nov 2026 · 8 min

When two XML documents look almost the same in an editor, glancing at them line by line is usually a poor way to find out what actually changed. Indentation shifts, attribute order, and empty lines can bury a real edit — a missing closing tag, a renamed element, or a single value that will break a parser later.

This guide walks through a practical way to compare XML in the browser, how to tell formatting noise apart from a meaningful change, and when you should switch to a stricter, schema-aware workflow.

Start with a side-by-side XML diff

The shortest path is a dedicated XML comparison tool, not a general text editor. Open the XML Diff tool on DiffCheck, paste the original document on the left and the updated document on the right, then compare. You can also paste HTML or SVG; they are treated as tag-based markup.

  1. Paste the older version on the left and the newer version on the right.
  2. Turn on Pretty-Print before you compare. This normalizes indentation so a file that was minified, or re-indented by an IDE, does not show up as hundreds of fake changes.
  3. Run the comparison and switch between split and unified views. Split is better for seeing context; unified is better for scanning a long list of edits.

The result should highlight added, removed, and changed lines, with a running count of each. If you only need the documents tidied first, run them through the XML Formatter and then come back to the diff.

Why pretty-print matters more for XML than for plain text

XML is routinely rewritten by tools. A Maven POM, a Spring config, an Android manifest, or an API response might be semantically identical after a formatter runs, yet every line can move. If you diff those files as raw text, you will spend time reviewing whitespace instead of the change that matters.

Pretty-print is not full XML canonicalization. It will not reorder attributes, collapse equivalent namespace prefixes, or ignore the difference between <item></item> and <item/>. Treat it as a way to remove indent noise, then inspect the remaining highlights.

If two documents still look completely different after pretty-print, check these common causes first:

  • Attribute order. <user id="1" role="admin"> and <user role="admin" id="1"> are equivalent to an XML parser, but a text diff will mark the line as changed.
  • Namespace prefixes. Switching between xmlns:ns and a default namespace can rewrite every tag name in the file without changing meaning.
  • Self-closing tags versus empty elements, which many serializers treat as interchangeable.
  • CDATA versus escaped text, or mixed line endings when one file came from Windows and the other from a Linux build.

A realistic example: an API response that looked unchanged

Suppose yesterday's response was:

<order id="1042" status="paid">
  <item sku="A-19" qty="2"/>
  <shipping method="standard"/>
</order>

And today's is:

<order status="paid" id="1042">
  <item sku="A-19" qty="2" />
  <shipping method="express"/>
</order>

A naive text compare will flag almost every line. After pretty-print you can still see attribute order and spacing changes, but the change that matters is standard becoming express. That is the kind of edit you want a reviewer to notice in seconds, not after scrolling past reformatted tags.

What an online XML diff is good for

Use a browser XML diff when:

  • You received two XML payloads in an email, a ticket, or a log, and do not want to create a Git repository just to look at them.
  • You need to explain a change to someone who does not use an IDE.
  • You are checking a config, a sitemap, a POM, or a SOAP or REST body before deploying.
  • The documents may contain production data you do not want to upload to an unknown third-party service. DiffCheck runs the comparison in your browser; the XML stays on your device.

When you should not rely on a line-oriented XML diff

A line-oriented diff is the wrong tool if you need to prove two documents are logically equivalent, or if you are validating against an XSD. In those cases use xmllint --format or xmllint --c14n to canonicalize before comparing, a schema validator for structure and types, or an XML-aware tree diff for large documents with reordered siblings.

DiffCheck's XML tool is a best-effort pretty-print plus a line diff. It does not run schema validation, and it will not silently ignore a reordered attribute. If you are comparing HTML pages rather than well-formed XML, the HTML Diff tool is the closer starting point.

A short checklist before you trust the result

  1. Pretty-print both sides.
  2. Confirm both files use the same encoding. UTF-8 is the usual case.
  3. Search the diff for the business fields you care about — ids, amounts, statuses — rather than reading every moved tag.
  4. If the highlight set is huge, format both files in the same editor, save, and compare again.
  5. For a merge decision, finish in Git or your IDE so the change is recorded.

If you want to try this on a real pair of files, open the XML Diff tool, paste both versions, enable Pretty-Print, and compare.

Related tools