Online Diff Tool

Paste or upload two versions and see added and removed lines in git-style hunks, with options to ignore whitespace and case. Files stay on your device.

The interactive tool loads here when JavaScript runs.

About this tool

What is the Online Diff Tool?

The Online Diff Tool compares two versions of a text or file line by line and highlights what was added, removed or left unchanged. You can paste text into both sides or upload a file for each, and choose to ignore whitespace or letter case so formatting noise does not hide real changes.

The comparison uses the Myers diff algorithm, the same family of algorithm behind git diff, and groups changes into unified-diff hunks with up to three lines of context on each side. Changes that sit close together share one hunk, just as they do in git. Files are read with the browser's FileReader and never leave your machine.

It compares whole lines. A one-character edit shows as the old line removed and the new line added; there is no word-level highlighting inside a line, and it does not detect moved blocks.

  • Myers line diff with three lines of context per hunk
  • Ignore whitespace, ignore case and line number options
  • Paste text or upload text and source files (.txt, .md, .json, .js, .ts, .py, .go and more)
  • Navigate between changes, swap sides and download a plain-text diff report
  • All comparison happens locally in your browser
Read the guide: How Text Diff Works: Reading Changes Like a Code Reviewer

Updated

How to use the Online Diff Tool

  1. Choose Text to paste content, or File Upload to drop in one file per side.
  2. Put the older version on the Original side and the newer version on Modified.
  3. Toggle Ignore whitespace, Ignore case and Show line numbers as needed.
  4. Step through changes with the previous and next buttons, swap the sides, copy the result or download a text report.

Worked example

Two versions of a small config

Input

Original: host=db1, port=5432, pool=10, timeout=30 (one per line). Modified: host=db2, port=5432, pool=20, timeout=30, ssl=true

Output

One hunk @@ -1,4 +1,5 @@ with 3 additions and 2 deletions

Two changed lines count as two deletions plus two additions, and the new ssl line is a third addition. The unchanged lines between them are context, so everything fits in one hunk.

Background and insight

The first widely used diff program shipped with Unix in 1974, written by Douglas McIlroy and James Hunt. In 1986 Eugene Myers published "An O(ND) Difference Algorithm and Its Variations", which finds the shortest edit script between two sequences efficiently when they are mostly similar. That paper is still the basis of GNU diff and git's default diff.

A diff answers a narrower question than people expect: what is the smallest set of whole-line insertions and deletions that turns A into B? It does not understand moves, renames or meaning. If you reorder two functions, a line diff shows one deleted and re-added. That is why reviewers sometimes see a "huge" diff for a change that is conceptually small.

Whitespace is the most common source of noise. An editor that converts tabs to spaces or strips trailing spaces can mark every line as changed. Ignoring whitespace collapses runs of spaces and trims line ends before comparing, so you see the edits that matter, while ignoring case helps with SQL keywords, HTML tags and other case-insensitive content.

Common use cases

  • Comparing configuration

    Find the one setting that differs between staging and production config files.

  • Reviewing edits to documents

    See exactly what changed between two drafts of a spec, contract or README.

  • Checking generated output

    Compare the output of a script before and after a change to make sure only the intended lines moved.

  • Investigating logs

    Diff two log excerpts to find where a good run and a failing run diverge.

Tips and limitations

  • Sort both sides first when order does not matter (lists of packages, environment variables). Otherwise a reordering looks like many changes.
  • Windows files end lines with CRLF. If every line looks changed, turn on Ignore whitespace, which also trims the trailing carriage return.
  • Minified JSON is one line, so any change marks the whole file as different. Beautify both sides with the JSON Formatter before comparing.
  • For prose, put one sentence per line before diffing. Line-based diffs are much easier to read that way.
  • Timestamps and request IDs make every log line unique. Strip them with a find-and-replace before diffing two runs.

Sources and further reading

  1. An O(ND) Difference Algorithm and Its Variations, Algorithmica. Eugene Myers' 1986 paper
  2. An Algorithm for Differential File Comparison, Bell Laboratories. Hunt and McIlroy's 1976 report on the original Unix diff
  3. GNU diffutils manual: Comparing and Merging Files, GNU Project. Includes the options for ignoring whitespace and case
  4. git-diff Documentation, Git. The diff algorithms git offers, with myers as the default

Frequently asked questions

Does this diff tool use the same algorithm as git?

It uses the Myers algorithm, which is git's default diff algorithm, and the same three-line context and hunk headers. Git also offers patience and histogram algorithms, which can produce cleaner results for heavily restructured code, so output can differ slightly on large refactors.

Why does every line show as changed when the files look identical?

Usually line endings or indentation changed, for example CRLF versus LF, tabs versus spaces, or trailing spaces added by an editor. Turn on Ignore whitespace and compare again. If lines still differ, check for invisible characters such as a byte order mark or non-breaking spaces.

Are files I compare in the online diff tool uploaded?

No. Files are read in your browser with the FileReader API and compared locally in JavaScript. Nothing is sent to a server, so it is reasonable for internal configs and documents, though you should still be careful with files that contain credentials.

Can the diff tool compare word by word?

No, the comparison is line-based, so a single changed word shows as the whole line removed and re-added. For prose, put each sentence on its own line before comparing, or use git diff --word-diff locally when you need changes highlighted inside lines.

What does @@ -1,4 +1,5 @@ mean in the diff report?

It is a unified diff hunk header. -1,4 means the hunk starts at line 1 of the original and covers 4 original lines; +1,5 means it starts at line 1 of the modified version and covers 5 lines. Lines starting with - were removed and + were added.

Is there an in-depth guide to the Online Diff Tool?

Yes. “How Text Diff Works: Reading Changes Like a Code Reviewer” covers the background, how it works, common pitfalls and worked examples. Read the full guide.