Text Diff
Compare two versions of a text and see every line, word or character that changed.
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
- 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.
- 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.
- 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.
- 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.
- 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?
How do I give it the second text?
Why does the copied patch show a change the summary called identical?
What does Ignore whitespace changes actually do?
Can it compare files rather than pasted text?
Why does the side-by-side view stop partway?
Does it highlight what changed inside a line?
Related tools
- JSON Formatter — Pretty-print, collapse and inspect JSON instantly.
- Base64 Encoder Decoder — Encode and decode Base64 text and files.
- JWT Decoder — Inspect the header, payload and claims of a JWT.
- Hash Generator — Compute MD5, SHA-1, SHA-256 and SHA-512 digests.
- Regex Tester — Test patterns against sample text with live matches.
- Unix Timestamp Converter — Convert between epoch seconds and readable dates.