Skip to main content

Text Diff Checker: Compare Two Texts

Compare two text inputs and review their differences. Use the comparison when checking revisions to writing, configuration, or code.

Diff Checker workspace

Original Text

Modified Text

Differences will appear here after comparison...

Latency: Instant Comparison
Security: 100% Browser-Side

Features

Line-by-Line Comparison

LCS algorithm marks each line added, removed, or unchanged with real line numbers

Side-by-Side View

Original on the left, modified on the right, with colored change gutters

Live Change Stats

Counts added, removed, and unchanged lines plus a change percentage

Inline Unified View

All changes in one stream with classic + and - prefixes, like git diff

Copy & Download

Export to a .txt unified diff with --- / +++ headers in one click

Privacy First

Runs 100% in your browser. No uploads, tool input is not sent to Toolk

Free Online Diff Checker to Compare Two Texts

Compare two text inputs and review their differences. Use the comparison when checking revisions to writing, configuration, or code. Text comparison is sensitive to representation. Whitespace, line breaks, and formatting can create changes even when the underlying data means the same thing. To compare parsed JSON values independently of key order, use JSON Diff instead.

How to use the diff checker

  1. Paste the original version into the left Original Text box (or click Load Example to try a sample).
  2. Paste the new version into the right Modified Text box.
  3. Pick a View Mode: Side by Side for two columns, or Inline for a single unified stream.
  4. Press Compare. Removed lines turn red, added lines turn green, unchanged lines stay neutral.
  5. Read the stats bar for the count of + added, - removed, and unchanged lines.
  6. Click Copy or Download to export the result as a unified .txt diff.
  7. Use Swap to flip which side is original, or Clear to start over.

How the diff algorithm works

Toolk splits both inputs into lines, then computes their Longest Common Subsequence (LCS) with a classic dynamic-programming table. The LCS is the longest ordered set of lines the two versions share. Anything in the original but not in that subsequence is marked removed; anything in the modified version but not in it is marked added. This is the same line-matching idea Eugene Myers formalized in his 1986 paper "An O(ND) Difference Algorithm and Its Variations", which unified the shortest-edit-script and LCS problems that drive git diff.

The export follows the unified diff convention standardized in POSIX.1-2008 (The Open Group diff utility): a --- line for the original, a +++ line for the modified file, then each line prefixed by + (added), - (removed), or a space (context).

Side-by-side vs. inline view

Both modes use the same comparison; they only differ in layout. Pick the one that matches your task.

AspectSide-by-Side ViewInline (Unified) View
LayoutTwo parallel columnsSingle continuous stream
Change markerColored left gutter per column+ / - prefix per line
Line numbersOriginal and modified, separatelySequential change stream
Best forReviewing structure and reorderingPatch logs and code review

Worked examples

The built-in example compares a JavaScript function before and after a refactor. Here is roughly what the inline (unified) output looks like:

--- original
+++ modified
- function greet(name) {
-   console.log("Hello, " + name);
-   return true;
+ function greet(name, greeting = "Hello") {
+   console.log(greeting + ", " + name + "!");
+   return { success: true };
  }

  const user = "World";
- greet(user);
+ const result = greet(user, "Hi");

Config drift example. Compare two .env files and only the changed keys light up. Input A has PORT=3000; input B has PORT=8080. Because each whole line is matched, the diff reports the old line removed and the new line added, even though only four characters changed.

Failing edge case — trailing whitespace. The line name: api (with one trailing space) does not match name: api. The live comparison is exact, so a stray space or a tab-vs-spaces change shows the entire line as removed and re-added. If that is noise, strip whitespace first with Find and Replace.

Unified diff symbol reference

These are the line markers in the exported toolk-diff-result.txt file.

SymbolMeaningSource
---Header for the original fileOriginal
+++Header for the modified fileModified
+Line added in the modified versionModified only
-Line removed from the originalOriginal only
(space)Unchanged context line, in bothBoth

The memory limit most diff tools never mention

Toolk's comparison fills a full (m + 1) × (n + 1) dynamic-programming table, where m and n are the line counts of the two sides. That means both time and memory grow as O(m × n), not the near-linear O(ND) of git's optimized Myers implementation. The practical effect: two 50-line inputs build a ~2,600-cell table and finish instantly, but two 20,000-line files would allocate a ~400-million-cell table and can stall the browser tab. For very large files, diff in smaller sections or use a command-line tool. Most web diff checkers hide this; we state it so you know the real ceiling.

One more honest note: the export writes +/-/space line prefixes and ---/+++ headers, but it does not emit @@ -l,s +l,s @@ hunk headers. It is a readable change log, not a patch you can feed straight into git apply.

What people compare with it

Code review

Spot exactly which lines changed between two revisions before you commit. Pair it with the JSON Formatter to normalize payloads first so the diff is meaningful.

Config drift

Compare a working .env, .yaml, or nginx config against a broken one to find the changed key. For structured data, the dedicated JSON Diff compares by value.

Content edits

Track changes between two drafts of an article or contract. Run the Word Counter to confirm length targets after editing.

Last updated: September 15, 2026 · Runs 100% in your browser — no uploads, tool input is not sent to Toolk.

Frequently asked questions

What algorithm does this diff checker use?

It splits both inputs into lines and computes the Longest Common Subsequence with a dynamic-programming table — the same line-matching idea Eugene Myers formalized in 1986 and that underlies git diff. Lines outside the subsequence are reported as added or removed.

Why does my huge file slow down or stall the tab?

Both time and memory grow as O(m × n): two 20,000-line inputs would build a ~400-million-cell table before rendering. Diff very large files in smaller sections instead — most web checkers share this ceiling but never state it.

Why does an invisible trailing space mark a whole line as changed?

The comparison is exact per line, so name: api with one trailing space does not match name: api without it — you get a remove-plus-add pair even when only whitespace moved. Strip stray spaces first with Find and Replace if that noise hides real edits.

Can I apply the exported diff with git apply?

No. The export writes ---/+++ headers plus +/- and context prefixes as a readable change log, but it does not emit @@ hunk headers or line numbers, so patch tools will reject it. Use it for review records, not for applying changes.

Do the texts I compare get uploaded?

No. The comparison, unified-diff formatting, and download are processed locally in your browser, and Toolk's page analytics do not receive your text — which is why comparing private configs and unreleased code here is safe.

Need a different tool?

Browse all 103 browser-based tools (103 currently marked free), or tell us what useful utility we should build next.

Browse all tools