HandyBench

Diff Checker

Compare two texts line by line.

How to use the Diff Checker

  1. 1 Paste the original text on the left and the changed text on the right.
  2. 2 Toggle "ignore case" or "ignore whitespace" if needed.
  3. 3 Read the highlighted additions, deletions and unchanged lines.

How the comparison is calculated

The checker splits each box into lines and finds the longest common subsequence (LCS) of lines. That is the longest list of lines that appear in both texts in the same order. Every line outside that list is either a deletion from the original or an addition in the changed text. The result is a minimal set of line edits, though not necessarily the one a human would choose when several are equally small.

It uses Myers' O(ND) algorithm, the same family of method as git diff. The work grows with the number of lines that differ, not with the product of the two file sizes, so two 20,000-line files with a handful of edits compare instantly. Lines that are identical at the start and end of both texts are skipped first. There is one limit: if the two texts differ by more than 3,000 lines (additions plus deletions), the tool stops and shows a "too much to compare" message instead of risking a frozen tab. In that case compare smaller sections, or use a command-line tool such as git diff.

Worked example

Compare a, b, c, d with a, B, c, d, e (one line each):

  a
- b
+ B
  c
  d
+ e

The counters read 2 additions, 1 deletion and 3 unchanged. The edited line shows as a deletion followed by an addition, because the checker works on whole lines and highlights nothing inside a line. When the algorithm could place a deletion or an addition first, it puts the deletion first.

The two options

  • Ignore case lower-cases both lines before comparing. With it on, b and B count as unchanged.
  • Ignore whitespace collapses each run of spaces and tabs to one space and trims the line ends. x  y and x y then match, but a missing space (xy) still differs.

Unchanged lines are displayed using the original text, so a case or spacing difference you chose to ignore is invisible in the output. Blank lines are compared too, so an extra empty line at the end counts as an addition.

Reading the results well

  • A moved paragraph appears as a deletion in one place and an addition in another, since the tool does not detect moves.
  • If almost everything is marked changed, suspect reflowed hard-wrapped text. Wrapping the same sentence at another width changes every line.
  • For structured data, format both sides the same way first. Run two JSON blobs through the JSON formatter so that key layout does not drown out real changes.
  • To rewrite text across a file after spotting a pattern, use find and replace.

The output is a view on screen only. It does not produce a unified diff or patch file, so copy the highlighted lines manually if you need to share them.

Examples

  • ▸ Spotting what changed between two versions of a config file.
  • ▸ Comparing two drafts of an article.

Frequently asked questions

Is my text sent to a server?

No. The comparison runs entirely in your browser, so code and documents you paste stay on your device.

How does the line diff work?

It uses the Myers O(ND) algorithm, as git does, to find the smallest set of line additions and deletions that turn the original into the changed text. Identical lines at the start and end are skipped first, so large files with few edits compare instantly.

Is there a size limit?

Large files are fine as long as they do not differ much. If the two texts differ by more than 3,000 lines (additions plus deletions) the tool shows a message instead of a result, because comparing them would freeze the browser. Compare smaller sections, or use git diff for very large changes.

Why is an edited line shown as one deletion and one addition?

The comparison works on whole lines, so a line with any change is removed and re-added. The checker does not highlight the changed words inside a line.

What do the ignore case and ignore whitespace options do?

Ignore case lower-cases both lines before comparing. Ignore whitespace collapses runs of spaces and tabs to one space and trims line ends. Unchanged lines are displayed with the original text.

Does it detect moved blocks, or work on very large files?

It does not detect moves, so a moved paragraph appears as a deletion and an addition. The comparison table grows with both line counts multiplied, so files of tens of thousands of lines can make the page slow.