FormatterHQ

XML Diff – Compare XML Online

Compare two XML documents without noise from indentation or line breaks. Both files are checked for well-formedness, re-indented and compared line by line.

Loading tool…
Ready.

How to use the XML Diff - Compare XML

  1. Paste the original XML on the left and the modified XML on the right, or load each side with Open file.
  2. Opened files are re-indented automatically; after pasting, untick and re-tick Normalize XML to re-indent both sides the same way.
  3. Tick Ignore whitespace or Ignore case if those differences should not count. A side that is not well-formed is marked Invalid XML with its line number.
  4. Review the highlighted differences in Side by side or Unified view and step through them with Prev and Next.

Compare XML by content, not formatting

XML files from different tools rarely look alike: one puts every attribute on a new line, another writes the whole document on one line, a third indents with tabs. A plain text diff drowns the real changes in that noise. This XML diff checks that both documents are well-formed and re-indents them the same way, with two spaces per level (the Normalize XML option, on by default). The two versions are then compared line by line, so the highlighted lines reflect content changes instead of layout.

Example

<book id="bk101" lang="en"><author>Gambardella, Matthew</author><price>44.95</price></book>

compared with

<book id="bk101" lang="en">
  <author>Gambardella, Matthew</author>
  <price>39.95</price>
</book>

reports a single difference, the <price> value (the summary reads 1 change +1 −1), because the one-line layout of the first document is normalized away.

Options explained

  • Normalize XML (on by default) – re-indents both sides with two spaces per level, so a document written on one line lines up with an indented one. Files you open and the sample are re-indented automatically; after pasting or typing, untick and re-tick the box to re-indent both sides.
  • Ignore whitespace – spaces and tabs at the start and end of a line, and runs of them inside a line, no longer count as changes.
  • Ignore case – compare text case-insensitively.
  • View – Side by side or Unified, and Collapse unchanged to fold long unchanged stretches and keep three lines around each change.

Attribute order and <!-- … --> comments are compared exactly as written; there is no option to sort attributes or to skip comments.

Worked example: generated comments

Build tools often stamp files with a comment that changes on every run, which hides the real change in a diff. Compare these two pom.xml fragments:

<!-- Generated 2026-09-01 10:14 -->
<dependency><groupId>org.example</groupId><artifactId>parser</artifactId><version>1.4.0</version></dependency>

<!-- Generated 2026-09-02 08:31 -->
<dependency>
  <groupId>org.example</groupId>
  <artifactId>parser</artifactId>
  <version>1.4.1</version>
</dependency>

After normalization the comparison shows two changed lines, the timestamp comment and the version (2 changes +2 −2). Comments are always compared, so delete the generated comment line on both sides, which you can do directly in the editors. Only the version bump from 1.4.0 to 1.4.1 remains (1 change +1 −1), which is the change a reviewer actually needs to see. Once both sides are normalized, the different indentation of the two fragments does not appear as a difference at all.

Validation first

If either document is not well-formed (an unclosed tag, a stray &, mismatched quotes), the header of that side shows Invalid XML with the line number and the status bar gives the parser message. That side is left as typed instead of being re-indented. Fix it, or check the file in the XML validator, and compare again.

Where an XML diff helps

  • Configuration files – Maven pom.xml, .NET .csproj and web.config, Android manifests and Spring contexts.
  • API payloads – SOAP requests and responses, or XML exports from ERP and e-commerce systems.
  • Feeds – RSS or sitemap files before and after a change.
  • Documents – SVG graphics or other XML-based formats edited by different tools.

Tip: compare canonical output

If you control both systems that produce the XML, the most reliable comparisons come from canonical output: consistent encoding, sorted attributes and no generated timestamps. Normalizing here removes the layout differences without changing either system; attribute order and comments have to match at the source.

Limits

The comparison is line based after normalization, so moving an element to a different position shows up as a removal and an addition, and namespace prefixes are compared literally. Attributes are compared in the order they are written, so <a x="1" y="2"> and <a y="2" x="1"> count as different lines. Whitespace inside text content is significant in XML and is compared as is unless you tick Ignore whitespace. For JSON data, use the JSON diff; to format a single document for reading, use the XML formatter.

Both documents are processed in your browser and are not uploaded.

Frequently asked questions

Does attribute order affect the result?
Yes. Attributes are compared in the order they are written, so the same attributes in a different order show up as a changed line even though the order has no meaning in XML. Put them in the same order on both sides to remove that difference.
Why do I get an invalid XML error?
One of the documents is not well-formed, for example because of an unclosed tag or an unescaped ampersand. The message names the side and line; fix it and compare again.
Are comments compared?
Yes, always. There is no option to skip them, so a generated timestamp or tool name in a comment shows up as a changed line. Delete such comments on both sides if they hide the change you are looking for.
What happens if an element moves?
Because the documents are compared line by line after formatting, a moved element appears as removed in one place and added in another.

Last updated October 3, 2026

Related tools

Diff Checker - Compare Text Compare two texts side by side and highlight every added, removed and changed line and word. Free online diff checker. File Diff - Compare Files Compare two files online and see line-by-line differences side by side or in a unified view, with the changed characters highlighted. JSON Diff - Compare JSON Compare two JSON documents semantically: find added, removed and changed keys with JSON paths, ignoring key order and formatting. Base64 to XML Decode a Base64 string back to XML with syntax highlighting. Compare PDF Compare the text of two PDFs and see every added, removed and changed sentence side by side. Ignores line breaks. No upload. Compare CSV Files Compare two CSV files by key column or row position: see added, removed and changed rows with old and new values, then export the differences. CSV to XML Converter Convert CSV to XML online for free. Attributes, arrays and root element are configurable. Excel to XML Converter Convert Excel to XML online for free. Attributes, arrays and root element are configurable. HTML Table to XML Converter Convert HTML to XML online for free. Attributes, arrays and root element are configurable. JSON Merge Patch (RFC 7396) Apply an RFC 7396 JSON Merge Patch to a document, or create the merge patch that turns one JSON document into another. JSON Patch Tester (RFC 6902) Apply RFC 6902 JSON Patch operations (add, remove, replace, move, copy, test) to a document and see exactly which step fails. JSON Patch Generator (Diff to Patch) Compare two JSON documents and generate the RFC 6902 JSON Patch that transforms the first into the second, with optional test ops.