XML Compare Tool: Differences Between Two XML Files

Paste two XML documents to see, node by node, which tags, attributes and text were added, removed or changed.

Comparing two XML files: how nodes are matched and read

The comparator parses both documents with the browser's XML parser, then compares the trees node by node: tag name, attributes (in any order) and the direct text of each element. Elements carrying an id attribute are matched by that identifier, all others by position. Every node ends up added, removed, modified or unchanged.

How the tool matches elements

Both texts must first be well-formed XML; otherwise the tool shows a parsing error and compares nothing. Then, for each element:

  • children with an id attribute are paired by the value of that id, even if their order changed;
  • children without an id are paired by rank (first with first, second with second);
  • an element is modified when an attribute is added, removed or changed, or when its direct text differs. Text is trimmed, so indentation and line breaks are ignored.

Example with the sample files

Version 1: root with version = 1.0, a settings block where theme is dark, two users (id 1 Alice, id 2 Bob with role Admin). Version 2: version = 1.1, theme is light, an extra notifications tag, Bob becomes SuperAdmin and a user with id 3 (Charlie) appears. Result: 3 modified nodes (the root for its attribute, theme, Bob's role), 4 added nodes (notifications, user 3 and its two children) and 3 removed (user 1 with name and email). User 2 itself stays unchanged but contains a change.

Limits

  • When two elements at the same rank have different tag names or different ids, the new one is marked modified and all its children added; the old children are not listed as removed.
  • Only text nodes are read: CDATA sections, comments and processing instructions are not compared. A namespace prefix is part of the compared name.
  • In a list without ids, inserting an element at the top shifts all the following ones, which then show as modified. The code view, a line-by-line diff in the Monaco editor, helps in that case.

In live mode the comparison reruns 0.8 seconds after the last keystroke. Unchanged branches are collapsed, and uploaded files are read in the browser without being sent anywhere.

Frequently Asked Questions

Does attribute order or indentation count as a difference?

No. Attributes are compared as a set after their names are sorted, and each element's text is trimmed, so indentation and line breaks between tags are ignored. A changed attribute value, even by one character, does mark the element as modified.

How do I compare a list of elements whose order changed?

Give each element an attribute named exactly id: the tool then pairs them by identifier regardless of position. Without an id, pairing is by rank, and an element inserted at the top makes all following ones show as modified. Other attribute names (key, ref, code) are not used for matching.

Why does the tool show an XML parsing error?

At least one of the two documents is not well-formed: an unclosed tag, an unescaped & character, several root elements or a misplaced declaration. As long as both texts do not pass the browser's parser, no comparison runs. The format button does not help here because it does not fix syntax.

Are CDATA sections and comments compared?

Not in the tree view: it only reads each element's direct text nodes and its attributes. A change limited to a comment or a CDATA section does not show up there. The code view, which compares the raw text line by line, does show it.

Is this tool really free?

Yes, all tools on Kristools are 100% free and accessible without registration.

Is my data protected?

Yes. All processing is performed directly and securely inside your browser. No personal data is sent to our servers.