skillfed

xmldiff

Creates diffs of XML files

xmldiff v3.0 374.3K downloads/30d#7,147 on PyPI229
Permissive license MIT Active released

What it is and what it does

xmldiff is a Python library and command-line tool that detects and reports changes between two XML documents in a way that respects XML's hierarchical structure. Unlike a line-by-line text diff, xmldiff understands that XML is tree-structured data and produces diffs that are meaningful to humans—useful when XML is used as a format for hierarchical data that will be rendered or displayed. The library offers multiple interfaces: a command-line tool for quick comparisons, a Python API with methods like diff_files(), diff_trees(), and diff_texts() for programmatic use, and support for different output formats including one that marks up differences directly in the XML.

The package is a complete rewrite from earlier versions, focusing on correctness and usability over raw speed. It handles large files without memory leaks and provides a cleaner, more Pythonic API. It depends only on lxml for XML parsing and is actively maintained, supporting Python 3.8 through 3.15.

Use it for:

  • Compare XML configuration files to see what settings have changed between versions or deployments.
  • Generate human-readable diffs of XML-based document formats (e.g., office documents, SVG) for review or audit trails.
  • Detect structural changes in XML data feeds or API responses for testing or monitoring purposes.
  • Patch XML files using diffs produced by xmldiff via the xmlpatch command.
  • Integrate XML change detection into CI/CD pipelines or version control workflows.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

xmldiff compares two XML files or trees and produces a human-readable diff that accounts for the hierarchical structure of XML, rather than treating it as flat text.

Yes. xmldiff solves a real problem—traditional diffs are unreadable for hierarchical data—and does so with low install friction, active maintenance, permissive licensing, and no known vulnerabilities. Use it if you need to compare XML files or trees in a way that makes sense to humans; skip it if you only need line-by-line text diffs.

Install

xmldiff on PyPI

pip

pip install xmldiff

uv

uv add xmldiff

poetry

poetry add xmldiff

Installing xmldiff

Before you install

Low friction: single pure-Python dependency (lxml), actively maintained with a release 64 days ago, and supported across Python 3.8 through 3.15 including PyPy.

License in practice

MIT license is permissive; you can use, modify, and distribute xmldiff with minimal restrictions, making it suitable for both open-source and proprietary projects.

Quickstart

from lxml import etree
from xmldiff import main, formatting

diff = main.diff_files('file1.xml', 'file2.xml',
                       formatter=formatting.XMLFormatter())

Requires lxml, which has compiled C dependencies; ensure your environment can install it (may need system libraries on some platforms).

Verify before relying

  • Performance characteristics relative to other XML diff tools or to the earlier 0.6/1.x versions.
  • Stability of the output format across future releases (documentation notes rapid development and no version-to-version guarantees).

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 1 — lxml
Maintenance actively maintained — 64 days since the last release
Last repo commit
First released
Downloads 374,264/month — #7,147 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: xmldiff-3.0-py3-none-any.whl

Keywords: diff, html, xml

Development Status :: 4 - BetaIntended Audience :: DevelopersIntended Audience :: End Users/DesktopLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.15Programming Language :: Python :: Implementation :: PyPyTopic :: Text Processing :: Markup :: XML

Tags

xml diff comparisonhierarchical xml changesxml file differdetect xml changesxml patch toolhuman readable xml diffxml tree comparison
xml-toolsdiff-utilities

More XML packages