--- id: xmldiff version: "3.0" license: MIT license_treatment: permissive maintenance: active --- # xmldiff — Creates diffs of XML files License: permissive · Maintenance: active · Downloads: 374.3K/mo ## 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 above — 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 pip install xmldiff uv add xmldiff 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_current - Install friction: low - Maintenance: active - Downloads: 374.3K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags xml diff comparison, hierarchical xml changes, xml file differ, detect xml changes, xml patch tool, human readable xml diff, xml tree comparison, xml-tools, diff-utilities [View on SkillFed](https://skillfed.io/packages/xmldiff) · [View on PyPI](https://pypi.org/project/xmldiff/)