Quick Answer

A text diff tool compares two blocks of text and highlights exactly what changed: additions in green, deletions in red, and unchanged text left plain. To use one, paste your original into the first box and the revised version into the second, and the differences appear instantly. It's the fastest way to spot every edit between two versions.

A text diff tool compares two versions of text and instantly shows you what changed between them, with additions and deletions highlighted so nothing slips past you. You paste the original into one box and the revised version into another, and the tool marks every edit. It turns the tedious job of eyeballing two nearly identical documents into a two-second glance.

Free Tool

Follow along with our free Text Diff tool. Paste two versions, see the differences light up instantly. It runs entirely in your browser, so your text never leaves your device.

Open the Text Diff Tool →

What Is a Text Diff Tool?

A text diff tool, sometimes called a diff checker or text comparison tool, finds the difference between two pieces of text. The word "diff" is short for difference, and the concept comes straight from the Unix diff command that programmers have used since the 1970s to compare files. Some tools show the two versions side by side, others stack the changes inline. Either way, you see the edits at a glance rather than reading both versions in full and hoping to catch the one word that moved.

How Do You Use a Text Diff Tool?

  1. Paste your original text. Drop the first version into the left or top box. This is your "before".
  2. Paste the changed text. Put the revised version into the second box. This is your "after".
  3. Read the highlights. The tool marks what was added, removed, or kept.

You can usually switch the comparison mode or ignore whitespace too. Pair it with our remove duplicate lines tool or word counter when you're cleaning up text.

How Does a Diff Tool Actually Work?

A diff tool solves one problem: what's the smallest set of edits that turns text A into text B? It finds the longest sequence of content the two texts share, then treats everything else as additions or deletions. In "An Algorithm for Differential File Comparison", Bell Laboratories Computing Science Technical Report #41, dated July 1976, J. W. Hunt and M. D. McIlroy wrote that "the central algorithm of diff solves the 'longest common subsequence problem' to find the lines that do not change between files."

The method most tools use today comes from Eugene W. Myers's 1986 paper "An O(ND) Difference Algorithm and Its Variations", published in Algorithmica. Its cost depends on N, the combined length of the two texts, and D, the size of the smallest edit script. In his words, the algorithm "performs well when differences are small (sequences are similar) and is consequently fast in typical applications." It is still Git's default, as the table below shows.

So two large, nearly identical files diff quickly, while two texts with little in common, or a file where every line was reformatted, can crawl or give up. If a diff hangs, reduce D before you split the file: ignore whitespace, normalize line endings, or switch to line mode.

How Do You Read a Diff Output?

Every diff view uses the same three signals:

  • Green, or a leading +, means added. It is only in the second version.
  • Red, or a leading -, means removed. It is only in the original.
  • Plain text means unchanged. It's context.

The original diff used letters instead: a, c and d for append, change and delete, with old lines flagged < and new ones >. A line reading 3,4c4,6 means lines 3 to 4 of the original became lines 4 to 6 of the revision. The unified format Git prints gives the same change as a start line and a line count, so with no context lines its hunk header reads @@ -3,2 +4,3 @@.

Browser tools use color instead, and red and green is the worst pairing for anyone with red-green color vision deficiency. W3C success criterion WCAG 1.4.1, Use of Color, sits at Level A and requires that "Color is not used as the only visual means of conveying information, indicating an action, prompting a response, or distinguishing a visual element." So prefer a tool that adds a second signal, such as plus and minus markers or strikethrough on deleted text.

What Are the Different Comparison Modes?

Most tools let you choose how finely to split the text before comparing, and picking the right mode makes the result far easier to read.

ModeCompares byBest for
LineWhole lines at a timeCode, config files, structured data
WordIndividual wordsProse, essays, editing drafts
CharacterSingle charactersSpotting a typo or a changed digit

Line mode is the classic and what Git shows you by default. Word mode suits regular writing. Character mode is precise but busy, so save it for a tiny change like one wrong digit.

Git can do word-level comparison too. Its documentation describes --word-diff, which by default delimits words by whitespace and shows removals as [-removed-] and additions as {+added+}. Useful when a prose file has been rewrapped and line mode turns the whole paragraph red.

Which Diff Algorithm Should You Use?

In a browser tool you usually don't choose, and you don't need to. In Git you can. The official documentation for --diff-algorithm lists four options:

AlgorithmWhat the Git docs sayWhen it helps
myers"The basic greedy diff algorithm. Currently, this is the default."Almost everything. Leave it alone unless a diff reads badly.
minimal"Spend extra time to make sure the smallest possible diff is produced."Small files where you want the tightest possible result.
patience"Use 'patience diff' algorithm when generating patches."Refactors where blocks moved and the default output looks scrambled.
histogram"This algorithm extends the patience algorithm to 'support low-occurrence common elements'."Code full of repeated lines, like closing braces or blank lines.

The choice matters. Nugroho, Hata and Matsumoto measured it in "How Different Are Different diff Algorithms in Git?", published in Empirical Software Engineering. Across 14 Java projects, code churn metrics came out different in 1.7 to 8.2 percent of commits depending purely on which algorithm ran, and across 10 Java projects, between 6.0 and 13.3 percent of identified bug-fix commits pointed at a different bug-introducing change. The authors "strongly recommend using the Histogram algorithm when mining Git repositories."

That research is about mining history at scale. For everyday reading the default is fine, and a noisy diff is more often whitespace than the algorithm: Git's -w flag will "ignore whitespace when comparing lines."

Why Does a Moved Paragraph Show Up as Deleted and Added?

Because to the algorithm, that's exactly what happened. A longest common subsequence has to keep its original order, so a block that jumps from line 5 to line 400 can't stay in it. The only way to say "this text is now somewhere else" is delete it here, insert it there. There is no move operation.

The fix is a second pass that spots the pattern afterwards. The git diff documentation describes --color-moved simply: "Moved lines of code are colored differently." The mode "defaults to no if the option is not given and to zebra if the option with no mode is given." Only "blocks of moved text of at least 20 alphanumeric characters" count in blocks mode, so a short moved line still reads as delete and add. A block that was moved and re-indented isn't byte-identical any more, which is what --color-moved-ws=allow-indentation-change is for: it groups moved lines into a block "if the change in whitespace is the same per line."

Most browser diff tools don't do move detection at all, and switching between line, word and character mode won't change that. Three ways to work around it:

  • Diff the moved block on its own. If the old and new copies compare clean, it moved unchanged.
  • Compare sorted versions when order doesn't matter. Sort lists, keys or CSV rows on both sides first.
  • Check the totals. Equal red and green line counts suggest a move.

It matters because one word quietly edited inside a moved block looks exactly like the color around it.

Can a Diff Tool Catch Invisible Characters?

Yes, and this is the job a diff tool does that nothing else does as well. Some characters are impossible to tell apart by eye. The Latin letter a and the Cyrillic а at code point U+0430 render the same in most fonts. So do Latin o and Greek omicron ο at U+03BF. The Unicode Consortium catalogues these in Unicode Technical Standard 39, Unicode Security Mechanisms, which ships a confusables.txt data file mapping visually confusable characters so software can detect when two strings are confusable.

Then there are invisible ones: zero-width spaces, non-breaking spaces and pasted smart quotes, all of which break string comparisons and config parsing. A diff tool finds them because it compares code points rather than shapes. Switch to character mode, which narrows the change to the exact position, and trust the tool over your eyes: if it insists two apparently identical strings differ, they differ. When a config value that reads perfectly won't parse, paste the working version and the broken one into a diff and the culprit usually lights up.

Why Do Some Diffs Flag Text That Is Genuinely the Same?

Because the same character can be stored more than one way. Take the letter é. It can be a single code point, U+00E9, or a plain e followed by a combining acute accent at U+0301. Same letter, same pixels on screen, different bytes underneath, and a diff comparing code points marks it as changed.

Unicode Standard Annex #15, Unicode Normalization Forms, calls this canonical equivalence, "a fundamental equivalency between characters or sequences of characters" that represent the same abstract character. The fix is normalization, which rewrites text into one consistent form. UAX #15 defines four forms. The usual choice is NFC, "Canonical Decomposition, followed by Canonical Composition", and the standard's design goal is that if two strings x and y are canonical equivalents, then toNFC(x) = toNFC(y). So:

  • If normalizing both sides to NFC makes the difference vanish, it was canonical equivalence. Nothing was really edited.
  • If the difference survives normalization, you're looking at genuinely different characters, the confusables or invisible-character case above, and now it's worth hunting.

Most browser diff tools don't normalize for you, which is the right default: quiet normalization could hide a real change.

Why Does Diffing JSON or XML Give Such Noisy Results?

Because a text diff compares characters, and structured formats let identical data be written many different ways. JSON is the common case. The IETF specification, RFC 8259, notes that "JSON parsing libraries have been observed to differ as to whether or not they make the ordering of object members visible," and that implementations which don't depend on member order interoperate. Reorder the keys and a text diff sees a rewritten file. XML has the same problem.

  • Reformatting changes everything. Minified to pretty-printed changes every line but no data.
  • Reordered keys read as delete plus add, exactly like the moved-block case above.
  • The real change hides in the noise. Reformat a config file and edit one value in the same commit, and the value change is lost in the wall of color.

The fix is to canonicalize both sides before you compare. Run both through the same formatter with the same settings, sort the keys if your tool offers it, then diff. Our JSON formatter does the formatting half, and the JSON formatter guide covers the settings that matter.

What Happens When You Diff a Word File or a PDF?

You compare a shadow of it. Copying out of a Word document or PDF leaves most of what changed behind. A .docx is an Office Open XML package (ECMA-376, also published as ISO/IEC 29500), and copying pulls out only the rendered text. Here's what doesn't come with you:

  • Tracked changes and comments, which live as markup, not visible text.
  • Styles and numbering. A term that stopped being bold, or a renumbered clause, pastes identically.
  • Headers, footers, footnotes and fields, which are usually outside your selection or copy only what they display.

That produces the dangerous failure mode: a paste-based diff can show no difference between two documents that genuinely differ. A quiet diff is the one people act on.

PDFs fail the other way: pasted PDF text arrives with line breaks at visual line ends, interleaved columns and split hyphenated words, so you compare two reconstructions. What to do instead:

  • Use the application's own compare. Word's Compare feature works on the document model, so it sees renumbering, styles and revisions.
  • If you must paste, paste both sides identically. Same application and paste mode, so extraction artifacts cancel out.
  • Treat a clean result as unproven. If a paste diff shows nothing, the honest report is that the visible text matches, not "no changes".
  • Go back to the source format when the stakes are real. If two PDFs came from two Word files, compare the Word files.

Why Does the Whole File Show as Changed When You Didn't Touch It?

Nine times out of ten, line endings. You open a file written on a Mac, save it on Windows, and every single line turns red and green even though you edited nothing.

POSIX, IEEE Std 1003.1-2024, defines a line at 3.185 as "a sequence of zero or more non-<newline> characters plus a terminating <newline> character." The terminator is part of the line, so switching between Unix LF (0A) and Windows CRLF (0D 0A) really does change every line.

Git's git diff documentation describes --ignore-cr-at-eol as "ignore carriage-return at the end of line when doing a comparison," which is narrower and safer than -w. The durable fix is gitattributes: the text attribute "enables end-of-line conversion: When a matching file is added to the index, the file's line endings are normalized to LF in the index," and with text=auto Git "decides by itself whether the file is text or binary." Everyone commits LF and the phantom diffs stop.

In a browser tool, character mode showing a change at the end of every line is the signature.

Other phantom diffs have their own shape:

What you seeLikely causeWhat to do
Every line changed, no visible editCRLF against LFIgnore carriage returns, then normalize the file properly
Only the final line changedTrailing newline added or removedLook for the no-newline marker; set your editor to be consistent
Only the first line changedUTF-8 byte order markSave both files with the same BOM setting
Scattered line ends changedTrailing spaces or tabsIgnore whitespace at end of line, or strip it on save

How Do You Check a Diff Tool Really Runs in Your Browser?

Every diff tool says it works locally. You can check in fifteen seconds, on any tool including this one. Open the Network panel first. Press F12, click Network, then paste your text and run the comparison. Per the Chrome DevTools network reference, DevTools records all network requests so long as DevTools is open. If your text is uploaded, a request appears when you hit compare.

Then go offline. In the throttling menu, switch to Offline and compare your two texts again. If the diff still works with the network switched off, the comparison is happening on your machine. That's proof rather than a promise.

Check what fires on the way out. MDN says navigator.sendBeacon() sends its data "without delaying unload or the next navigation," which is precisely when you've stopped looking. Tick Preserve log, navigate away, then read what fired. Judge the payload, not the number of requests: an analytics ping carrying a page URL is ordinary, a POST whose body contains your contract text is not.

For anything you'd be genuinely hurt to leak, an offline tool on your own machine removes the question.

What Mistakes Should You Avoid?

  • Using the wrong mode. Running a character diff on two long essays buries the real changes in noise. Match the mode to the content.
  • Forgetting about whitespace. A file that only had its indentation reformatted can look completely rewritten. Turn on "ignore whitespace" when the spacing doesn't matter, and if every line is flagged, check the line endings first.
  • Pasting sensitive text into a server-based tool. For a contract or private code, use a tool that works in your browser so nothing is uploaded.
  • Assuming diff means merge. A diff shows changes; it doesn't combine them. If you need to blend two versions, you want a merge tool.
  • Comparing texts that are formatted differently. One version with curly quotes and another with straight quotes will show differences that aren't really edits. Normalize the formatting first.

Keep the Text Diff tool in a tab, and check our free tools for developers and guide to free online developer tools for the rest of the kit.

What Else Do People Ask?

What is a text diff tool?

A text diff tool compares two blocks of text and highlights exactly what changed between them: what was added, what was removed, and what stayed the same. You paste an original and a revised version, and the tool marks the differences line by line or word by word. Our free Text Diff tool runs entirely in your browser.

How do you compare two texts online?

Open a text diff tool, paste your original text into the first box and the changed version into the second, then let it highlight the differences. Additions usually show in green and deletions in red. Adjust the comparison mode to word, line, or character level depending on how fine-grained you want the result to be.

Is it safe to paste text into an online diff tool?

It depends on the tool. The safest ones do all the comparison in your browser, so your text is never uploaded to a server. That matters for anything private, like a contract draft or unreleased code. Check that the tool says it works locally, and for truly sensitive material, prefer a browser-based tool or an offline one over anything that sends your text away to process it.

What is the difference between word, line, and character diff?

They control how finely the tool splits the text before comparing. Line diff marks whole lines as changed and suits code and structured files. Word diff highlights the specific words that changed and reads best for prose and editing. Character diff goes down to individual letters, which is handy for spotting a single typo or a changed digit but can look noisy on longer text.

Can a diff tool merge changes?

Some can, but a basic diff tool only shows the differences. Merging means combining two versions into one, choosing which change to keep where there is a conflict. Full version control systems like Git include merge tools, and some online diff checkers offer a merge view.

This guide describes how typical browser-based text diff tools work. Features like comparison modes, whitespace handling, and merge views vary between tools. For sensitive documents, always confirm that the tool processes your text locally in the browser rather than uploading it to a server.