Format Code Now
/

XML Diff

FV-35

Paste two XML documents separated by a line with only ===== and see what changed. Indentation, spacing and attribute order are ignored.

Runs in your browser. Nothing is uploaded.

Two XML documents separated by a line with only =====

Differences

How to use it

  1. Paste the first XML document, then a line with only =====, then the second document.
  2. Leave Ignore attribute order ticked unless the order matters to you. Tick Ignore comments to skip comments.
  3. Choose how many lines of context to show around each change.
  4. Click Compare and read the unified diff.

How the comparison works

Plain text diffs show changes that mean nothing in XML, such as different indentation or attributes in a different order. So each document is first rewritten in one standard layout: one tag per line, indented by depth, attributes in double quotes and sorted by name, runs of whitespace in text collapsed to a single space, and an empty element always written as <a/>. The two layouts are then compared by line and shown as a unified diff, with the number of lines added and removed.

What is and is not treated as equal

Both documents must be well-formed, and an error names the side and the line. Spacing differences and attribute order are ignored, so the tool can report no difference for two documents whose text differs. Text, element order and attribute values are compared exactly. Namespace prefixes are compared as written, so the same namespace under two prefixes shows as a change. The XML declaration is ignored, and CDATA is not turned into escaped text.

Error messages and what to do

MessageWhat it meansFix
Separator not found. Put a line with only ===== between the two texts.There is no line made only of five equals signs.Add the separator line between the two documents.
Second XML (below =====): <b> opened on line 1 is never closed at line 1, column 4The second document has a tag that is never closed.Close the tag and compare again.

Questions people ask

How do I compare two XML files?

Paste both into the box with a line containing only ===== between them and click Compare. Lines starting with - exist only in the first document and lines starting with + only in the second.

Does attribute order matter in XML?

No, attribute order has no meaning in XML, which is why the option to ignore it is ticked by default. Element order does matter, so a moved element shows as a change.

Why does it say there are no differences when my files look different?

Indentation, line breaks between tags, extra spaces in text, attribute order, and <a></a> versus <a/> are all treated as the same, because they do not change the data.

Can it ignore comments?

Yes. Tick Ignore comments and comments are removed from both documents before they are compared, so a changed or added comment does not show up as a difference.

Can I compare XML with a different namespace prefix?

Not as equal. The prefix is compared as written, so ns1:item and a:item show as different even if both prefixes point to the same namespace.

What if one of the XML documents is invalid?

You get an error that says whether the first or second document has the problem, with a line and column. Fix it and compare again.

About this tool

Both documents must be well-formed XML; if not, the error says which side and where. Each is then rewritten the same way: one tag per line, indentation by depth, attributes in double quotes (sorted by name unless you untick it), runs of whitespace in text collapsed to one space, whitespace-only text dropped, and an empty element written as <a/> whether or not it had a closing tag. The XML declaration is ignored. The two results are compared by line, and the output is a unified diff. Because whitespace is normalised, a change that only adds or removes spacing is reported as no difference. Namespace prefixes are compared as written, CDATA is not turned into escaped text, and entities other than the five built-in ones and numeric references are not supported.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.