Skip to main content

Text Diff / Compare

Compare two texts side by side and highlight the differences.

Reviewed by · Last reviewed

How to Use the Text Diff Tool

  1. Paste the original version of your text into the left panel. This can be a paragraph, an email, a translation source, or any prose passage.
  2. Paste the edited version into the right panel.
  3. Click Compare. The diff view renders below, showing each line that changed with added content highlighted in green and removed content in red.
  4. Scan for unchanged lines in gray between the change markers - that is your context, the prose both writers agreed on.
  5. Use Swap to see the diff from the opposite direction, which reveals whether an edit was an addition or a reversion.
  6. Use Clear to reset both panels before starting a fresh comparison.

What This Tool Does

The diff runs as a line-based comparison with an emphasis on short, human-readable passages: release notes, blog edits, translation reviews, and chat threads. Behind the scenes it uses a longest-common-subsequence computation to align matching lines between the two inputs, then marks everything else as insertions or deletions. Rendering is done by building DOM text nodes rather than innerHTML, which means angle brackets, ampersands, and other HTML-looking characters in your prose are rendered verbatim instead of being parsed as markup. Nothing about the comparison touches the network: there is no fetch, no telemetry beacon carrying the input, and the Compare button triggers a single synchronous function call within the existing page context.

When You Would Reach for It

  • Checking what an editor actually changed in the draft of a blog post before you accept their version.
  • Verifying that two translators produced linguistically equivalent output by diffing the English back-translations.
  • Reviewing terms-of-service changes between vendor contract revisions and flagging inserted clauses to legal.
  • Comparing two versions of an AI-generated response to see where a prompt tweak shifted the wording.
  • Auditing Slack or Discord messages pasted from two timestamps to see what a message author edited after the fact.
  • Confirming that a grammar or tone rewrite did not quietly drop a factual claim from the original paragraph.

Common Pitfalls and Edge Cases

  • Line-break-sensitive comparison. The tool compares whole lines. If the editor reflowed paragraphs at a different column width, every line will appear changed even though the words are the same. Paste one paragraph per line, or run both inputs through a line-flattening step first.
  • Smart quotes and em-dashes. Pasting from Word, Google Docs, or a CMS often introduces U+2018, U+2019, U+201C, U+201D, or U+2014 where ASCII characters used to be. These look identical on screen but are different bytes, so they appear as changes. An invisible-character detector (also on this site) reveals them.
  • Non-breaking spaces. U+00A0 looks like a normal space but is different from U+0020 and will cause a line to diff against an otherwise-matching line.
  • Trailing whitespace. Spaces or tabs at the end of a line count as differences. If they are uninteresting, trim them in a text editor or with the Whitespace Remover before diffing.
  • Identical inputs with trailing-newline mismatch. Two pastes that differ only by whether they end with a newline will show a one-line change at the bottom.

What "Text Diff" Actually Means

Text diffing has a long lineage that starts with Hunt and McIlroy's 1976 paper describing the algorithm that became Unix diff, followed by Eugene Myers's 1986 paper that introduced the O(ND) edit-script algorithm modern tools use. The underlying math is dynamic programming over a sequence of tokens - lines, words, or characters - searching for the longest common subsequence (LCS) that maximizes the unchanged portion between two inputs. RFC 6902 (JSON Patch) and the unified-diff format used by GNU diff and Git both grew out of this tradition. Word-level and character-level diffs use the same math applied to a finer granularity, which is why editors such as VS Code can show inline red and green within a single changed line.

Comparison to Alternatives

diff -u on the command line remains the reference tool for file-based text comparison. wdiff produces word-level diffs that are friendlier to prose readers than the line-level default. Google Docs, Notion, and Microsoft Word have built-in track-changes views that are far more ergonomic when the author and reviewer are collaborating inside the same document. Diffchecker.com and several other online tools offer side-by-side layouts with inline word-level highlighting. Use this web tool when your inputs are short passages pasted from somewhere else (a chat, an email, a model response) and you want a quick, private, zero-install comparison. For long documents with rich formatting, a Word-class editor with track changes will serve you better; for version-controlled content, Git is the right answer.

Frequently Asked Questions

How is this different from the diff-checker tool on this site?

The diff-checker page is optimized for file-to-file code comparison: it produces a unified-diff output suitable for git apply and patch, with dual line-number gutters and a monospace presentation. This text-diff page is tuned for shorter prose passages - emails, blog paragraphs, translation snippets - where you want a quick, readable change view rather than a machine-consumable patch. The underlying LCS math is similar but the UX decisions differ.

Why are two lines that look identical showing as changed?

The most common culprits are invisible Unicode characters: zero-width space U+200B, byte-order mark U+FEFF, non-breaking space U+00A0, or soft hyphen U+00AD. The second most common is a smart-quote substitution from a CMS converting straight quotes to curly. Paste the suspicious line into the invisible-character detector on this site to see every hidden code point with its name and position.

Does the text I compare get stored or uploaded?

No. The comparison runs as a single JavaScript function call inside your browser tab. There is no POST to any server, no service worker caching your inputs, and no analytics event carrying the text. Closing the tab releases the strings for garbage collection. If you want to verify, open DevTools and watch the Network tab while you click Compare - nothing appears.

Can I diff JSON or YAML with this tool?

You can, but a structural diff tool usually gives better results for data formats. This tool compares lines as-is, so reordering keys in a JSON object will show as a full rewrite of each object even though the semantic content is identical. Tools such as jd, jsondiff, or json-diff compare the parsed structures and report key-level changes that are order-independent, which is almost always what you want when reviewing API payload changes.

Why should I use this instead of track changes in my word processor?

Track changes is superior inside a living document where you and a collaborator share the file. This tool is for the case where you received two versions as pasted text - a chat message, a copy out of an email thread, a code review comment - and you just need to see the delta without opening either source application. It is also useful when the source is not a document at all: two LLM outputs, two versions of a log message, or two configuration files.

How does the LCS algorithm decide which lines are the same?

Longest common subsequence works on an edit-graph representation: it finds the longest sequence of lines that appears in both inputs in the same relative order. Lines not in that subsequence are reported as insertions or deletions. The algorithm is agnostic to what lines contain - it compares them for byte equality - so two lines differing by a single character are treated as unrelated rather than as a modification.

What about emojis and non-Latin scripts?

Comparison is byte-exact, so any two lines that encode to the same UTF-8 bytes are equal regardless of script. Arabic, Chinese, Hindi, and heavily-emoji-dotted text all compare correctly. The rendering uses your browser's default monospace font, which may not have glyphs for every script; in that case the Unicode replacement box appears but the diff is still mathematically correct.

Can I see a word-level diff rather than a line-level one?

This tool reports at the line level. If you want word-level differences inside a paragraph, either pre-split the prose so one sentence lives on each line before diffing, or use a dedicated word-level tool. GNU wdiff and the npm package diff offer word and character granularity if you need something scriptable.

How large can each side be?

Comfortable up to a few thousand lines per side; beyond that the browser may freeze briefly while the edit graph is walked because LCS is quadratic in the worst case. For book-length manuscripts or huge logs, use a command-line tool written in C or Rust - GNU diff handles multi-megabyte inputs without breaking a sweat.

Does the tool normalize line endings between the two inputs?

No. If one side has Windows CRLF and the other Unix LF, every line will appear changed because the trailing \r is part of the line. Run both inputs through a normalizer first if you pulled them from mixed sources. On macOS and Linux, tr -d \r does the job; on Windows, dos2unix is the standard fix.

More Text Tools