Text Diff

Compare two versions of a text and see every line, word or character that changed.

Runs on your deviceDeveloperWorkingNo account needed

What this tool does

Text Diff hands both versions to a diff library that runs inside the page and reports the shortest set of edits turning one into the other. Compare by chooses the unit. Lines treats a whole line as a single token, Words splits on word boundaries while keeping the spaces between them, and Characters steps through one character at a time. The summary counts what moved: added, removed and unchanged lines in Lines mode, added and removed characters in the other two — so swapping cat for dog in Words mode reads as three characters added and three removed, rather than as a single changed word.

Lines mode builds two views of the same comparison. The side-by-side table sets the first version against the second, tinting added rows green, removed rows red and a replaced pair amber; where a removed block is immediately followed by an added one, the lines are paired by position rather than by similarity, so an uneven pair leaves a blank cell on one side. Behind that sits a unified patch: a row of equals signs, then --- first and +++ second where a command-line tool would name two paths, then @@ hunks whose body is the +/- listing diff -u produces. Context lines decides how much unchanged text surrounds each hunk — 0 for the tightest patch, up to 20. That patch is what Copy output puts on the clipboard, and it is written in full while the table stops drawing at 2000 rows. Lines mode also gives both sides exactly one trailing newline before it starts, so a file missing its final newline does not turn its last line into a change.

The two ignore switches deserve a close read, because each reaches less far than its label suggests. Ignore case lowercases both sides before matching. Ignore whitespace changes trims every line in Lines mode, so indentation and trailing spaces stop counting — and the rows on screen lose that indentation with them — while in Words mode it makes any run of spaces equal to any other, and in Characters mode it does nothing at all. Wherever a difference is being ignored, both columns show the second version's text, so a line differing only in case appears twice in the second spelling. The one to keep in mind: the unified patch is generated from the untouched text without either switch, so with an ignore option on it can list a change that the counts above it call identical.

Neither version leaves this tab: both are held in memory on your own machine and matched there. The one thing that crosses the network is the diff library itself, requested from this site when you run the first comparison and taken from the browser cache on every one after that, so a second run needs no connection at all. What limits the tool is scope rather than privacy. It compares text you can paste, with no file picker, so a PDF or a Word document has to have its text pulled out first; and identical here means identical as characters, never as meaning. Two neighbouring tools take the jobs this one should not: JSON Diff matches two JSON documents by key instead of by line, and Compare PDFs reads two PDFs and diffs the text page against page.

How to use it

  1. Paste the first text. The First text box takes it. Load sample fills that box instead with two four-line blocks separated by a --- line, differing in two places: one word swapped, one word inserted.
  2. Supply the second text. The settings panel holds a Second document box for it. If you would sooner keep both versions in one place, leave that box empty and put a line containing only --- between them in the input; the Separator line field changes that marker to anything else.
  3. Choose the unit of comparison. Lines for files, code and logs; Words for prose; Characters for a single identifier or string. Lines is the only mode that produces a patch and a side-by-side table.
  4. Set the ignore switches and the context. Ignore case and Ignore whitespace changes are both off to begin with. Context lines in the patch, from 0 to 20, controls how much unchanged text is printed around each hunk; the field appears only while Lines is selected.
  5. Read the result, or copy it. The output pane shows the coloured comparison. Copy output gives the unified patch in Lines mode, or text marked with [-removed-] and {+added+} in the other two.

Processing & privacy

Runs on your device. Your file is processed directly in this browser.

Common use cases

Seeing what a colleague edited in a draft

Words mode marks the clause that actually changed, instead of turning a whole reflowed paragraph red because one sentence was retouched.

Diffing two config files away from a terminal

Lines mode with a context of 3 gives the same hunks diff -u would, labelled first and second instead of two file paths, on a machine with no checkout and no shell to hand.

Finding the one character that breaks a string

Two API keys or slugs can look identical while differing by a trailing space or a hyphen that is really an en dash. Characters mode marks the exact position.

Judging the size of a change before reviewing it

The line counts say whether the difference between two log excerpts or two responses is one line or two hundred, which decides how carefully it needs reading.

Questions

Is my text uploaded?
No. Both versions are matched inside this browser tab, so neither one is transmitted or stored anywhere. The only request the diff checker makes is for its own diff library, which this site serves on the first run and the browser holds afterwards; your text is not part of it.
How do I give it the second text?
Either put it in the Second document box, or keep both versions in the input box with a line containing only --- between them; that separator is editable. With neither in place the run stops and explains what is missing rather than comparing your text against nothing.
Why does the copied patch show a change the summary called identical?
The counts and the side-by-side table honour Ignore case and Ignore whitespace changes, while the unified patch is built from the raw text without them. When an ignore switch is on the two can disagree, and it is the summary that reflects your settings.
What does Ignore whitespace changes actually do?
In Lines mode it trims each line before comparing, so indentation and trailing spaces stop counting and the displayed rows lose that indentation. In Words mode any run of spaces matches any other. In Characters mode it has no effect, because characters are compared singly.
Can it compare files rather than pasted text?
No. This page has no file picker — both versions go in as text, so anything binary needs converting first. Compare PDFs takes two PDFs directly and reports the difference in their page text.
Why does the side-by-side view stop partway?
It draws 2000 rows and then says so beneath the table, which keeps a very long comparison from freezing the tab. The unified patch behind Copy output is complete, so use that for anything longer.
Does it highlight what changed inside a line?
Not in Lines mode: a replaced pair is tinted as a whole line on both sides, with no word-level marking within it. Switch to Words to see which words moved, which is why prose reads better in that mode.

Related tools