Text

Text Diff / Compare

Compare two blocks of text and see exactly what changed — line by line and word by word — with a similarity score and added/removed counts. 100% in-browser, no upload, no signup, no ads.

By the Samastam teamLast updated

Paste two versions of any text above. The differences appear here automatically — line by line, with changed words highlighted. Everything is computed locally in your browser; nothing is uploaded.

A text diff shows you precisely what changed between two versions of the same text: which lines were added, which were removed, and which words shifted inside an edited line. Paste an original on the left and a changed version on the right, and the comparison is computed entirely in your browser using a classic longest-common-subsequence algorithm.

What this is and why it matters

A text diff is the difference between two versions of the same content, expressed as a set of edits: lines that were added, lines that were removed, and lines that stayed the same. Instead of re-reading two documents side by side and hoping you spot the changes, a diff isolates only what moved. This is the same idea that powers version control, code review, and the "track changes" feature in a word processor — the underlying question is always "what is different between A and B, and where?"

Getting the answer right matters because the naive approach — comparing line one to line one, line two to line two — falls apart the moment a single line is inserted near the top. Every line after the insertion shifts down by one, so a dumb comparison reports the entire rest of the file as changed even though only one line was actually added. A proper diff avoids this by finding the longest common subsequence of lines: the largest set of lines that appear, in the same order, in both texts. Anything outside that common backbone is a genuine add or remove, and the noise disappears.

Precision is the whole point. When you are reconciling two drafts of a contract, two revisions of a config file, or two copies of a paragraph a colleague edited, you need to trust that a line marked unchanged really is unchanged, character for character. A tool that computes the diff deterministically gives you that guarantee. It is also why doing this locally beats pasting sensitive text into a chat assistant: the algorithm is exact, repeatable, and it never sends your words anywhere.

How to use this tool

Paste your two versions into the two panes. Put the earlier or reference version in the Original box on the left, and the newer or edited version in the Changed box on the right. There is no submit button — the comparison recomputes automatically as you type or paste, so you see the result immediately.

Choose how much to ignore. Turn on "ignore case" if a difference in capitalisation should not count as a change — useful when comparing text that was re-cased by a formatter. Turn on "ignore leading/trailing whitespace" if indentation or trailing spaces were reflowed and you only care about the visible content of each line. Both toggles affect how lines are matched, so the similarity score and the highlight counts update the moment you flip them.

Pick a view mode. Side-by-side puts the original and the changed text in two aligned columns, which is the most natural way to read a document revision. Unified collapses both into a single stream with removed lines marked by a leading minus and added lines by a leading plus, which is closer to how code review tools present changes and is easier to scan on a narrow screen.

Read the summary and the highlights. The header shows a similarity percentage and the number of added and removed lines. In the panes, added lines carry a jade tint, removed lines carry a terracotta tint, and within a line that was edited rather than wholly replaced, only the specific words that changed are highlighted — so you can zero in on the exact edit at a glance.

Examples and use cases

Comparing two versions of a config file

A developer is debugging why a service behaves differently between staging and production. They copy the staging YAML into the Original pane and the production YAML into the Changed pane. The diff instantly shows that only three lines differ: a timeout was raised from 30 to 60, a feature flag flipped from false to true, and a log level changed from info to debug. Everything else is marked unchanged, so the developer can stop scanning hundreds of identical lines and focus on the three that actually explain the behaviour. The word-level highlight makes it obvious that it was the value 30 that became 60, not the whole timeout line being rewritten.

Reconciling two drafts of a contract clause

A founder receives a redlined indemnity clause back from the other side’s lawyer and wants to know exactly what was changed before signing. Pasting the original clause and the returned version side by side reveals that a single phrase — “within thirty (30) days” — was quietly changed to “within ninety (90) days,” and one sentence about liability caps was removed entirely. Because the comparison runs locally, the sensitive contract text never leaves the founder’s laptop, and because the word-level diff pinpoints the changed phrase, the edit is impossible to miss in what otherwise looks like an unchanged paragraph.

Checking what an editor changed in a code snippet

A writer pastes a function into a documentation article and later a reviewer edits it. To confirm the edit did not break the example, the writer diffs the two snippets. The unified view shows two removed lines and two added lines: a variable was renamed and a comment was reworded. The similarity score of 94% confirms the change was small and cosmetic rather than a rewrite, giving quick confidence that the surrounding prose still describes the code accurately.

Frequently asked questions

What is the difference between a line-level and a word-level diff?
A line-level diff treats each line as an atomic unit and tells you whether a whole line was added, removed, or kept. A word-level diff looks inside a line that changed and highlights only the specific words that differ. This tool does both: it first aligns the two texts by line using a longest-common-subsequence pass, then for lines that were edited rather than wholly added or removed, it runs a second word-level pass so a one-word change does not light up the entire line as different.
How is the similarity percentage calculated?
The similarity is based on how many lines the two texts share versus how many lines they have in total. Concretely, it is the size of the longest common subsequence of lines, scaled against the combined length of both versions. Two identical texts score 100%, a complete rewrite scores near 0%, and a small edit scores in the high 90s. It is a quick magnitude signal, not a formal edit-distance metric, so treat it as "how big is this change" rather than an exact character count.
What do the ignore-case and ignore-whitespace toggles actually do?
They change how two lines are judged to be equal during matching. With ignore case on, "Hello" and "hello" are treated as the same line, so a capitalisation-only change is no longer reported as a difference. With ignore leading/trailing whitespace on, indentation and trailing spaces are stripped before lines are compared, so reflowed indentation or stray trailing spaces do not show up as changes. The original text is still displayed exactly as you pasted it; only the matching logic is relaxed.
Why is an AI chatbot unreliable for an exact character-level diff?
A language model reads text as tokens and produces a fluent summary of what changed — it will tell you "the timeout was increased and a flag was flipped," which is often useful. But it does not guarantee character-level or line-level precision: it can silently miss a single changed digit, hallucinate a change that is not there, or gloss over whitespace and punctuation. A diff algorithm, by contrast, is deterministic and exact: it compares the actual characters and lines and marks every difference, no matter how small. When you need to trust that an "unchanged" line really is byte-for-byte identical, use a real diff, not a summary.
Is my text uploaded anywhere when I compare it?
No. The entire comparison runs in JavaScript in your browser. The text you paste into the two panes never leaves your device — there is no server call, no API, and nothing is logged or stored. That is deliberate, because the most common use for a diff is comparing sensitive material: unsigned contracts, private config, unpublished drafts, or code you are not ready to share. You can even disconnect from the network and the tool keeps working.
Can I compare very large blocks of text?
Yes, within reason. The tool works comfortably for documents up to a few thousand lines, which covers essentially every contract draft, config file, or article you are likely to compare. The line-level LCS runs in roughly the product of the two line counts, so extremely large inputs — tens of thousands of lines on both sides — can get slow because that is the nature of the classic algorithm. For everyday text and code review, it is effectively instant.
Does the diff detect a moved block of text?
Not as a distinct "moved" operation. Like most classic line-diff tools, this compares the two texts in order, so a block that was cut from one place and pasted elsewhere shows up as a removal in the old location and an addition in the new one, rather than a single move. The longest-common-subsequence approach keeps the largest in-order backbone intact, which minimises noise, but it does not track relocation. If you need move-detection you would want a specialised structural diff.

Sources

Related tools