ToolForge
Advertisement

Text Diff Checker

Compare two texts and see exactly what changed

Written by toolforge.websiteLast reviewed How we build and check these tools

Text Diff Checker tool

Nothing to compare yet.

Original

0 lines

Modified

0 lines

The unit version control uses. Best for code, config and data.

Differences

Paste two versions above, or press Sample, and the differences appear here.

Both texts are compared in this browser and never uploaded, so confidential drafts and configuration are safe to paste. They are kept on this device only while “Keep both texts in this browser” is ticked.

Text Diff Checker: key facts

What it does
Compare two texts and see exactly what changed
Category
Developer Tools
Cost
Free, with no account, sign-up, or install.
Your data
Runs entirely in your browser — the files and text you enter are never uploaded to a server.
Last reviewed
. Report an incorrect result.
Advertisement

Understanding the Text Diff Checker

Working out what changed between two versions of something — a contract clause, a config file, a paragraph of copy — is slow and unreliable by eye. This tool does it properly: it runs a real diff algorithm over the two texts and shows you the changes, with the original's line numbers down one side and the modified version's down the other.

"Properly" is doing some work in that sentence. The naive way to compare two texts is to line them up and check the first line against the first, the second against the second, and so on. It falls apart immediately: insert a single line at the top of a twenty-line file and everything below it shifts by one, so a comparison of that kind reports all twenty lines as replaced. A diff algorithm exists to find the longest sequence the two texts still share, which is why inserting one line here reports one added line and nineteen unchanged ones.

Changes inside a line are highlighted word by word, so a line that reports as changed also shows you which word did it — but only when the two lines are genuinely a rewrite of each other, because highlighting the differences between two unrelated lines is noise dressed up as information. You can compare by line, by word across the whole document, or character by character.

Long stretches with nothing in them collapse to a single click, so a two-thousand-line file with one edit reads in a glance instead of scrolling. And what you copy is a valid unified patch — proper hunk headers, no stray spaces after the markers — so it can be piped to patch or git apply rather than only read.

Reading a large diff, and getting it out

Most real comparisons are a small change in a large file, so showing every unchanged line is showing almost nothing useful. Stretches with no changes in them collapse to a single row naming how many lines it hides, with a few lines of context kept either side of each change — the amount is yours to set — and one click expands any of them. The up and down buttons step from one change to the next, which is the difference between reviewing a three-thousand-line file and scrolling through one.

The summary line counts what changed: lines added, removed, changed and unchanged, plus how similar the two texts are overall. It is the quickest way to sanity-check that you pasted what you meant to.

Copy gives you two things. "Copy patch" produces a unified diff with real hunk headers — the @@ lines that say where each change sits and how many lines it spans — which is a format other tools can consume rather than merely display. "Copy text" gives the plain reading view with plus and minus markers, for pasting into a review comment or an email. The patch can also be downloaded as a .patch file.

Getting a result

  1. Paste the original on the left and the modified version on the right, or drop a file onto either box.
  2. Choose what to compare by: lines for code and configuration, words for prose, characters for a changed identifier.
  3. Switch between the side-by-side and unified views, and set how many unchanged lines to keep around each change.
  4. Ignore case, whitespace or blank lines if those are not the changes you are looking for.
  5. Step through the changes with the up and down buttons.
  6. Copy the result as a unified patch, or download it as a .patch file.

What a diff algorithm actually does

The question a diff answers is not "are these two lines the same" but "what is the shortest set of insertions and deletions that turns the first text into the second". Those are very different questions, and only the second one survives an edit that shifts everything below it.

The method here is Myers' algorithm, the same one Git uses. It searches for the furthest it can get through both texts using a given number of edits, increasing that number until it reaches the end of both — which finds a minimal edit script rather than the first one it stumbles on. Before it runs, the shared beginning and end of the two texts are trimmed away, because the usual case is a small change in a large file and there is no sense searching the parts that obviously match.

One consequence worth knowing: a block of text that moved is reported as deleted from one place and added in another, because that is genuinely what the shortest edit script says. Detecting a move as a move is a separate problem, and one this tool does not claim to solve.

  • Insert one line at the top of a twenty-line file: one added line, twenty unchanged.
  • Delete one line from the middle: one removed line, nineteen unchanged.
  • Change one word in a long line: one changed line, with that word highlighted.

Reasons to use it here

  • A real Myers diff, the algorithm Git uses, so an inserted line is one added line rather than a file reported as wholly rewritten.
  • Correct line numbers on each side: the original's on the left, the modified version's on the right, absent where a side has no line at all.
  • Changed words highlighted inside a changed line, applied only where the two lines are genuinely a rewrite of one another.
  • Compare by line, by word or by character, so the unit matches the material.
  • Ignore case, indentation, trailing spaces, all whitespace or blank lines — the comparison changes, the text on screen does not.
  • Line endings are normalised before comparing, and a difference that turns out to be only line endings is reported as such.
  • Unchanged stretches collapse to a click, with adjustable context and buttons to step from change to change.
  • Copy a valid unified patch with proper hunk headers, or download it as a .patch file.
  • Both texts are compared in your browser and never uploaded, which matters for contracts, drafts and configuration.

Line endings, and comparing the right thing

Line endings cause more confusion than any other part of comparing text. Windows historically terminates a line with a carriage return and a line feed; Unix-derived systems use the line feed alone. A file that has crossed between them is textually identical and yet differs on every single line, which is exactly what version control's line-ending settings exist to prevent. This tool normalises both before comparing, and tells you when that was the only difference — because "these files differ only in line endings" is a useful answer, not something to hide.

Beyond that, match the comparison unit to the material. Lines suit code, configuration and logs, where a line is a meaningful unit. Words suit prose, where reflowing a paragraph moves every line break without changing a single sentence — comparing by word ignores where the lines happen to fall. Characters suit the case where one identifier or number changed and you want to see precisely which characters moved.

The ignore options handle the rest. Case, indentation, trailing spaces, all whitespace, or blank lines can each be excluded from the comparison — and excluded from the comparison only: the text on screen is always what is actually in your file, so turning on "ignore indentation" does not quietly reformat anything.

Frequently Asked Questions

Why do other comparison tools say my whole file changed when I only added a line?

Because they compare position by position — first line against first line, second against second — so an insertion shifts everything below it and every subsequent line looks different. A diff algorithm instead finds the longest sequence the two texts still share, which is why adding one line here is reported as one added line with the rest unchanged.

Can I see which word changed, not just which line?

Yes. When a line is reported as changed, the words that differ are highlighted inside it on both sides. This only happens when the two lines are similar enough to be a rewrite of each other — highlighting the differences between two completely unrelated lines would be noise. You can also switch the comparison to word or character granularity for the whole document.

Why does my file show as entirely different when it looks the same?

Usually line endings. Windows ends lines with a carriage return and a line feed, Unix with a line feed alone, so a file that has crossed platforms differs invisibly on every line. Both texts are normalised before comparison here, and if that turns out to be the only difference you are told so explicitly rather than shown a clean result you cannot explain.

Can I ignore formatting differences?

Yes — case, indentation, trailing spaces, all whitespace, and blank lines can each be excluded. The important detail is that they are excluded from the comparison only: what you see in the panes is always the text exactly as it is in your file, so nothing is silently reformatted.

Is the copied diff a real patch?

Yes. Copy patch produces a unified diff with correct @@ hunk headers and no space after the plus or minus markers, so it can be applied with patch or git apply rather than only read. There is also a plain text copy with markers for pasting into a review, and a .patch download.

Is my text kept private?

The comparison runs entirely in your browser and neither text is sent anywhere, so confidential contracts, drafts and configuration are safe to paste. Both texts are stored in this browser's local storage on this device only while the autosave box is ticked, and very long texts are never written there.

Related Tools

Advertisement
Buy Me a Coffee