Text Diff Viewer

Compare two blocks of text line by line and see exactly what changed. Everything runs in your browser, so configuration files and logs containing sensitive values stay on your machine. Capped at 2000 lines per side to stay responsive.




How the comparison works

The two texts are compared line by line using an LCS (longest common subsequence) algorithm, the same underlying approach Git and most diff tools use.

The idea: find the longest sequence of lines appearing in both texts in the same order. Those lines are the unchanged backbone. Everything in the original that is not part of it was removed, everything in the changed text that is not part of it was added.

Output notation follows the standard convention:

Why a modified line shows as two changes

Editing one word in a line produces a removal and an addition, not a single "modified" entry. This looks redundant but follows from how line-based diffing works.

The algorithm compares whole lines as units. Two lines are either identical or they are not, there is no partial match. A line whose content changed is therefore a line that disappeared and a different line that appeared.

The practical implication: keep lines short in files you expect to diff. A paragraph written as one long line produces a diff showing the entire paragraph replaced, even for a one-character typo fix. Writing prose with one sentence per line, or using semantic line breaks, makes diffs far more readable. The same applies to configuration files and to code formatting choices.

Reading the output

A worked example. Original:

server:
  host: localhost
  port: 8080
  debug: true

Changed:

server:
  host: example.com
  port: 8080
  timeout: 30

Produces:

  server:
- ..host: localhost
+ ..host: example.com
  ..port: 8080
- ..debug: true
+ ..timeout: 30

Reading it: server: and the port line are untouched, the host value changed (shown as removal plus addition), and the debug line was replaced by a timeout line. Note that the algorithm has no way to know whether the last pair is "one line replaced by another" or "one line deleted and an unrelated line added", it simply reports what differs.

Practical uses

Comparing configuration between environments

Paste a staging config and a production config to see exactly which settings differ. This is often faster than reading both files, and it catches the setting that was changed in one environment and forgotten in the other. Since nothing leaves your browser, configs containing credentials are safe to paste.

Checking what an editor or formatter changed

Run a formatter, then diff before against after. This shows whether the tool only reformatted whitespace or also altered something meaningful, which is worth verifying before committing a large automated change.

Comparing API responses

Diff two JSON responses to spot which fields changed between calls or between versions. Format both with the JSON formatter first, so each field is on its own line, otherwise a minified response is a single line and the diff is useless.

Reviewing text edits

Comparing two versions of a document, a licence text, or an email draft shows precisely what was altered, which is more reliable than reading both and trusting your memory.

Frequently asked questions

Why does changing one word mark the whole line as changed?

Because the comparison works on whole lines. A line with different content is a different line. Keeping lines short makes diffs more precise.

Does it detect moved blocks?

No. A block moved from one place to another appears as a deletion in the first location and an addition in the second. Move detection requires more sophisticated algorithms than standard LCS diffing.

Is whitespace significant?

Yes. Lines differing only in indentation or trailing spaces are treated as different. This is deliberate, since whitespace matters in languages like Python and in files where trailing spaces cause problems.

Why is there a 2000-line limit?

The LCS algorithm builds a table proportional to the product of both lengths, so cost grows quadratically. The cap keeps the page responsive instead of freezing on a large paste. For bigger comparisons, use a dedicated diff tool or git diff.

How are empty inputs handled?

An empty input counts as zero lines rather than one empty line, matching the behaviour of git diff. Comparing an empty original against text shows every line as added.

Is my text sent to a server?

No. The comparison runs entirely in your browser, which is what makes it safe for configuration files, logs, and unpublished documents.

Related tools