Registry / testing / icdiff

icdiff

JSON →
library2.0.10pypypi✓ verified 24d ago

icdiff is a Python library and command-line utility for displaying diffs with improved colorization, making it easier to read changes side-by-side. It aims to be a more user-friendly alternative to traditional `diff` output. The current version is 2.0.10, and it maintains a fairly active release cadence with updates typically every few months.

pip install icdiff
INSTALL
IMPORT
SIG · ICDIFF
I
icdiff
testingpythonv2.0.10
Install
1.5s avg
Import
31ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.10 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.036s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.026s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ConsoleDiff
from icdiff import ConsoleDiff
This is the main class for programmatic diff generation with console-style output.

This quickstart demonstrates how to use `ConsoleDiff` to generate a colored, side-by-side diff between two lists of strings. It configures the diff for a specific column width, includes line numbers, and sets custom file labels for the header.

from icdiff import ConsoleDiff old_text = [ "line 1: hello world", "line 2: foo bar", "line 3: baz qux" ] new_text = [ "line 1: hello earth", "line 2: foo baz", "line 3: baz qux", "line 4: new line" ] differ = ConsoleDiff( cols=80, # Specify number of columns for display line_numbers=True, # Show line numbers color=True # Enable color output ) diff_lines = differ.make_table( old_text, new_text, fromfile='old_version.txt', tofile='new_version.txt', context=True # Show context lines ) for line in diff_lines: print(line)
icdiff --version
Debug
Known issues
gotcha`icdiff` is primarily a command-line tool. While it offers a Python API, its main strength is interactive visualization. For purely programmatic diff parsing or generating diffs in non-console contexts, Python's built-in `difflib` might be more suitable or efficient, especially if raw diff data (not colored output) is needed.
fix
Consider `difflib` for non-visual, programmatic diffing or when fine-grained control over diff algorithm is required without console-specific formatting.
affects: All versions
gotchaThe `fromfile` and `tofile` arguments in `ConsoleDiff.make_table()` are purely for display labels in the diff header (e.g., `--- old_version.txt`). They do not instruct `icdiff` to read content from actual files. You must provide the file content as lists of strings.
fix
Always pass the actual content of the files as lists of strings (e.g., `file1.readlines()`) to `make_table()`. The `fromfile` and `tofile` arguments are just metadata for the output header.
affects: All versions
gotchaBy default, `ConsoleDiff` tries to output ANSI color codes. If you redirect `icdiff`'s output to a file or pipe it to another command, you might end up with escape codes in the output. While `icdiff`'s CLI often detects non-TTY, the Python API might require explicit handling.
fix
When using `ConsoleDiff` programmatically and outputting to a non-TTY (like a file), instantiate it with `color=False` (e.g., `ConsoleDiff(color=False)`) to prevent ANSI escape codes from being included in the output.
affects: All versions
Errors
Common errors & fixes
ImportError: No module named 'icdiff'
The `icdiff` library is primarily a command-line utility and is not designed to be imported as a Python module directly in most standard use cases. The main script does not typically function as an importable package.
fix
Use `icdiff` as a command-line tool: `icdiff file1.txt file2.txt`. If you require programmatic access, consider running it as a subprocess using `subprocess.run(['icdiff', 'file1.txt', 'file2.txt'], capture_output=True)` or ensure the `icdiff` script is on your Python path and rename it to `icdiff.py` if attempting a direct import, though this is not the intended usage.
IOError: [Errno 32] Broken pipe
This error occurs when `icdiff`'s output is piped to another command (like `less -R`) and the receiving command exits before `icdiff` has finished writing all of its output. `icdiff` attempts to write to a pipe that has already been closed.
fix
This error is generally benign and can often be ignored as the user has already received the desired output (e.g., by quitting `less`). To avoid the error, ensure the receiving process consumes all of `icdiff`'s output or redirects `icdiff`'s output to a file instead of a pipe if you need the full output processed without interruption.
icdiff doesn't work on windows (e.g., infinite memory usage, broken colors in Git Bash)
There are known compatibility issues with `icdiff` on Windows, especially when used within environments like Git Bash. These problems often stem from differences in terminal emulation, how color codes are handled, or interactions with the underlying `diff` utility, sometimes leading to high resource consumption or incorrect display.
fix
Try running `icdiff` directly in the native Windows Command Prompt (`cmd.exe`) or PowerShell for potentially better results with color support. If using Git, configure `icdiff` as your difftool, but be aware that specific terminal environments like Git Bash might still have limitations. Consider alternative diff tools if compatibility issues persist on your specific Windows setup.
Upgrade
Version history
2.0.10latest on PyPI · released Feb 8, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources
icdiff — pip install icdiff · libregistry