# Diff Checker Text Compare

URL: https://hifreetools.com/text/diff-checker

> Paste an original and a changed version to compare them line by line. The tool highlights added, removed, and unchanged lines and reports the totals.

## Quick answer

Paste your original text on the left and the changed text on the right. This diff checker runs a longest-common-subsequence (LCS) line comparison in your browser, marking each line as added (+), removed (-), or unchanged, and shows how many of each there are.

## Formula

- Line classification: unchanged = lines in the LCS of original and changed; removed = original line not in LCS (prefix -); added = changed line not in LCS (prefix +)

The two texts are split into lines. A longest-common-subsequence (LCS) algorithm finds the largest set of lines that appear, in order, in both versions; those lines are marked "unchanged." Lines that exist only in the original are marked "removed" (prefixed with -), and lines that exist only in the changed text are marked "added" (prefixed with +). Walking the LCS table from top to bottom produces a unified, in-order diff and a count of added, removed, and unchanged lines. Optional "ignore case" and "trim spaces" settings only affect how lines are matched — the original line text is always preserved in the output. Everything is computed locally in your browser, so nothing is uploaded.

## Examples

- One line changed: Original: apple banana cherry Changed: apple blueberry cherry → apple - banana + blueberry cherry (1 added, 1 removed, 2 unchanged)
- Line appended: Original: one two three Changed: one two three four → one two three + four (1 added, 0 removed, 3 unchanged)
- Line deleted: Original: cat dog bird Changed: dog bird → - cat dog bird (0 added, 1 removed, 2 unchanged)
- Identical text: Original: hello world Changed: hello world → hello world (0 added, 0 removed, 2 unchanged)

## FAQ

**How does this diff checker decide what changed?**
It uses a longest-common-subsequence (LCS) algorithm on the lines of both texts. Lines that appear in the same order in both versions are "unchanged," lines only in the original are "removed," and lines only in the changed text are "added."

**Does it compare line by line or word by word?**
It compares whole lines. If you edit a few words inside a line, that line is reported as one removed line and one added line rather than a partial change.

**What do the + and - symbols mean?**
A leading "+ " marks a line that was added (present only in the changed text) and a leading "- " marks a line that was removed (present only in the original). Unchanged lines have no marker. This matches the convention used by Git and unified diffs.

**Can it ignore capitalization or extra spaces?**
Yes. "Ignore case" matches lines regardless of upper/lowercase, and "trim spaces" ignores leading and trailing whitespace when matching. Both options only affect matching; the output keeps your original line text.

**Is my text uploaded anywhere?**
No. The entire comparison runs in your browser with JavaScript, so both blocks of text stay on your device and nothing is sent to a server.

**Can I copy the diff result?**
Yes. The result panel includes a copy button that copies the full unified diff, with + and - prefixes, so you can paste it into a message, ticket, or document.

**Does the order of lines matter?**
Yes. Because it uses a subsequence match, lines must appear in the same relative order to count as unchanged. Re-ordering blocks of text will show some lines as removed and re-added.


## Sources

- [Wikipedia — Longest common subsequence](https://en.wikipedia.org/wiki/Longest_common_subsequence)
- [Wikipedia — Diff](https://en.wikipedia.org/wiki/Diff)
- [Git Documentation — git diff](https://git-scm.com/docs/git-diff)

Runs in the browser; nothing is uploaded. Cite as: HIFreeTools, "Diff Checker Text Compare", https://hifreetools.com/text/diff-checker
