How to Compare Two Texts Online: Line, Word & Character Diff

·8 min read·Updated

"Which version has the typo?" is a question you shouldn't have to answer with your eyeballs. A good diff tool tells you in a glance. This post covers when to use line vs word vs character diff, how to prepare messy inputs so the diff is actually useful, and a couple of tricks that make the result far more readable.

The three diff modes

Line diff is the default in Git and every code review tool. It compares whole lines and highlights any line that isn't byte-identical. Best for: source code, formatted JSON, YAML, logs.

Word diff compares word-by-word inside changed lines. Best for: articles, contracts, translations — anywhere a single word swap matters more than the line it lives on.

Character diff goes down to individual characters. Best for: hunting a typo, comparing very short strings (variable names, IDs), or diffing text without spaces (URLs, hashes).

Preparing inputs so the diff isn't noise

The single biggest cause of unreadable diffs is trivial formatting differences. Before you compare:

  • Normalize whitespace and line endings. A CRLF vs LF mismatch or a stray tab-vs-space rewrites every line.
  • Format structured data first. Two functionally identical JSON documents will diff as 100% different if one is minified. Run both through a formatter first.
  • Strip volatile fields. Timestamps, request IDs, generated hashes — remove them or replace them with a placeholder before diffing snapshot outputs.

Reading the highlights

Every diff tool uses the same visual grammar:

  • Green — content added in the new version.
  • Red — content removed from the original.
  • Yellow / mixed — a line that changed. Word or character mode expands this into the exact edits.

Focus on the modified segments; the unchanged regions are context, not content.

The algorithm, in one paragraph

Modern diffs use the longest common subsequence (LCS) — they find the biggest set of lines (or words, or characters) that appear in the same order in both sides, then flag everything else as an add or remove. That's why moving a block often shows up as a large delete on one side and a large insert on the other, rather than a "move". It's mathematically correct, even when it doesn't match your intuition.

Real use cases

  • Contract review: word diff between the counterparty's redline and your last version — every changed clause pops.
  • Code review off-Git: line diff between two versions of a config file a colleague pasted into Slack.
  • Translation QA: character diff between the machine translation and the human edit to see exactly what the editor changed.
  • API response drift: line diff between yesterday's cached response and today's, after formatting both.

Which diff mode should you pick?

ContentBest modeWhy
Source code, YAML, configLineMatches how Git and code review present changes
Essays, contracts, marketing copyWordOne swapped word is the whole change
IDs, hashes, URLs, short stringsCharacterThe difference is often a single character
JSON API payloadsLine, after formatting both sidesMinified JSON diffs as one giant changed line
Translations and proofreadsWord, then characterWord finds the edits, character shows punctuation

How to compare two text files online without uploading them

  1. Open both files in any editor and copy the full contents of each.
  2. Paste version A on the left and version B on the right.
  3. Normalise first if the sources came from different systems — convert line endings and, for JSON or XML, run both through a formatter.
  4. Start in line mode to find where the change is, then switch to word or character mode on that region to see what changed.
  5. Copy the cleaned version back out.

Because the comparison runs in JavaScript on your own machine, nothing is uploaded — which matters when the two documents are a contract draft, a production config, or a customer export.

Comparing more than plain text

  • Word documents — copy the text out first; a diff tool compares characters, not styling or tracked changes.
  • PDFs — select and copy the text layer. Scanned PDFs have no text layer and need OCR before any diff is possible.
  • Spreadsheets — export both to CSV, then line-diff. Sort the rows by a stable key first or every reordered row shows as a change.
  • Code with reformatting — run the same formatter over both sides, otherwise the diff shows the formatter's work instead of yours.

Try it now

Paste two versions of anything into our Text Diff Checker. Switch between line, word and character modes to find the level of detail that makes the change obvious. Everything stays in your browser — no upload, no signup.

Comparing specific file types

  • Two Word documents: copy the text out of each into the diff tool, or use Word's own Review → Compare when you need tracked-change output.
  • Two PDFs: select and copy the text layer from each. Scanned PDFs have no text layer, so they need OCR first.
  • Two JSON files: format both with the same indentation before diffing, otherwise every line reads as changed. Our JSON formatter normalises them in one click.
  • Two CSV files: sort both by the same key column first; unsorted rows produce a diff that is technically correct and completely unreadable.
  • Code: word-level diff shows renamed variables clearly; line diff is better for reviewing structural edits.

Common questions about text comparison

  • How do I find the difference between two texts? Paste each version into a side-by-side diff and read the highlighted additions and deletions — you never need to scan manually.
  • Can I compare two texts without uploading them? Yes. Our diff checker runs entirely in your browser, so nothing leaves your machine — which matters for contracts, legal drafts and unreleased copy.
  • Why does everything show as changed? Almost always whitespace, line endings or indentation. Normalise both sides first with the text cleaner.
  • Which mode should I pick? Line for code and structured files, word for prose edits, character for spotting a single typo or a stray Unicode character.

Keep reading