unidiff
Unified diff parsing/metadata extraction library.
Decision gist · record as of 2026-08-14
Yes. Unidiff is stable (Production/Stable status), actively maintained, has no dependencies, and solves a clear problem—parsing unified diffs into queryable objects. Use it whenever you need to programmatically analyze patch files or diffs beyond simple text parsing.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.9 or later.
- Low friction: pure Python wheel with no runtime dependencies.
- Actively maintained with a recent release 20 days ago and steady commit activity.
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you can use this library freely in open-source and commercial projects with minimal restrictions.
last release 2026-07-25 (20 days) · last repo commit 2026-08-07 · 286 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 42,832,452 downloads/mo, #652 on PyPI
Alternatives
Verify before relying
pip install unidiff
from unidiff import PatchSet
patch = PatchSet.from_filename('file.diff', encoding='utf-8')
for patched_file in patch:
print(patched_file.path, patched_file.added, patched_file.removed)What it is and what it does
Unidiff is a Python library that parses unified diff format (the standard output of git diff, patch files, and similar tools) into structured objects you can query and manipulate. It reads diff data from files, strings, or file-like objects and exposes a tree of PatchSet → PatchedFile → Hunk → Line objects, each with metadata like line numbers, change type (added/removed/context), file modes, and symlink status.
You can inspect statistics (how many lines were added or removed per file), detect binary changes, extract individual hunks or lines, and reconstruct the original diff from modified objects. It also ships as a command-line tool that summarizes diff statistics. The library requires Python 3.9 or later and has no external dependencies, making it straightforward to integrate into build tools, code review systems, or any workflow that needs to analyze patches programmatically.
Use it for
- Parse git diffs or patch files in CI/CD pipelines to extract file change statistics and validate patch content.
- Build code review tools that need to inspect individual hunks and lines to flag specific changes.
- Analyze patch metadata (file modes, symlinks, binary status) in version control or deployment workflows.
- Extract and filter specific changes from large diffs for reporting or automated testing.
- Reconstruct or modify unified diffs by manipulating the object tree and regenerating the diff output.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Unidiff is stable (Production/Stable status), actively maintained, has no dependencies, and solves a clear problem—parsing unified diffs into queryable objects. Use it whenever you need to programmatically analyze patch files or diffs beyond simple text parsing.
Install
unidiff on PyPI
Before you install
Low friction: pure Python wheel with no runtime dependencies. Actively maintained with a recent release 20 days ago and steady commit activity.
Requires Python 3.9 or later.
License in practice
MIT license is permissive; you can use this library freely in open-source and commercial projects with minimal restrictions.
Quickstart
pip install unidiff
from unidiff import PatchSet
patch = PatchSet.from_filename('file.diff', encoding='utf-8')
for patched_file in patch:
print(patched_file.path, patched_file.added, patched_file.removed)
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 20 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 42,832,452 / month, #652 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python Modules |
Evidence: unidiff-1.0.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “diff parsing library”
- unidiffParses unified diff format data into structured Python objects,…
- unidiff2Parses unified diff format into structured Python objects…
- whatthepatchParses and applies patch files in multiple diff formats (unified,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also unidiff2 · moreorless · patch · types-unidiff · whatthepatch · patch-ng · diff-match-patch · diff-parser · icdiff · datadiff