🛠️ToolsShed

Diff Checker

Compare two texts and highlight the differences line by line.

Diff Checker compares two blocks of text side by side and highlights the exact lines or characters that have been added, removed, or changed. It uses the same underlying diff algorithm found in version control systems like Git, making the output immediately familiar to developers.

Paste your original text into the left panel and the modified version into the right panel, then click Compare. Added lines are shown in green, removed lines in red, and unchanged lines remain neutral, giving you an instant visual summary of every difference.

Common use cases include reviewing code changes before committing, comparing configuration files across environments, checking document revisions, and validating the output of a code generator against an expected result. No data is uploaded — all comparison happens in your browser.

Frequently Asked Questions

Code Implementation

import difflib

original = """line one
line two
line three
line four"""

modified = """line one
line TWO
line three
line five"""

# Unified diff (like git diff output)
diff = list(difflib.unified_diff(
    original.splitlines(keepends=True),
    modified.splitlines(keepends=True),
    fromfile="original.txt",
    tofile="modified.txt",
    n=2,  # context lines
))
print("".join(diff))

# Sequence matcher — similarity ratio
matcher = difflib.SequenceMatcher(None, original, modified)
print(f"Similarity: {matcher.ratio():.1%}")  # Similarity: 81.8%

# HTML diff for visual output
html_diff = difflib.HtmlDiff()
html = html_diff.make_file(
    original.splitlines(),
    modified.splitlines(),
    fromdesc="Original",
    todesc="Modified",
)

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.