← Back

Text Diff

Compare the differences between two texts

About Text Diff

The text diff tool puts two pieces of text side by side and uses a standard difference algorithm to find what was added and what was removed. The result is colour-coded in place: additions get a green background, removals get a red background with a strikethrough, and unchanged text stays plain. There are two levels of detail: 'Compare by line' suits config files, code snippets and lists, while 'Compare by word' suits prose and contract clauses where the edits are small. It compares only what you paste in; it does not merge texts or produce a patch file.

How to use it

  1. Paste the old version into 'Original text' on the left and the new version into 'Compare text' on the right. Both boxes start with sample text.
  2. Choose a mode with the buttons below: 'Compare by line' or 'Compare by word'. The active button has a dark background.
  3. Click 'Compare' on the right. The result does not refresh while you type, so after changing the text or switching mode you need to click 'Compare' again.
  4. Read the highlights under 'Comparison result'. The legend explains them: 'Added' is green and 'Removed (strikethrough)' is red.
  5. To focus on changes only, tick 'Show differences only (hide unchanged content)' and the unchanged parts are hidden.

A worked example (actually computed)

Take the built-in English sample. The original has the lines 'First line of text', 'Second line of text' and 'Third line of text'. The comparison text has 'First line of text', 'Second line of text, modified', 'Third line of text' and 'A new fourth line'. In 'Compare by word' mode the real output keeps 'First line of text' and 'Second line of text', adds a comma and the word 'modified', keeps 'Third line of text', and adds a line break followed by 'A new fourth line', which is a precise result. In 'Compare by line' mode the real output is: the first line kept, 'Second line of text' removed, 'Second line of text, modified' added, the third line kept, and 'A new fourth line' added. The tool first appends a newline to any text that lacks one, so the unchanged third line is not wrongly flagged.

What it supports and where it stops

  • Before a line comparison the tool appends a newline to any text that does not end with one, so a missing final newline no longer causes a false difference. Trailing spaces within lines and Windows versus Unix line breaks are still treated as content changes.
  • Line mode treats a whole line as one unit. Changing a single character shows the entire line as removed and added, so you can't see which character changed. Switch to word mode for that.
  • Word mode splits on whitespace and punctuation; when the text contains Chinese, Japanese or Korean characters it switches to character-by-character splitting (English words and numbers still count as words). Changing 我喜欢吃苹果和香蕉 to 我喜欢吃橙子和香蕉 marks only 苹果 as removed and 橙子 as added. Note that this does not understand word meaning or do word segmentation.
  • The same pair of texts can produce different-looking results in the two modes. That comes from the granularity, not from an error.
  • The comparison is case-sensitive and whitespace-sensitive. An extra space or different indentation is flagged.
  • The result panel has a maximum height and scrolls. There is no side-by-side view, no line numbers and no way to export the result.
  • Very large inputs (tens of thousands of lines) may be slow, because the calculation runs synchronously on the page.

FAQ: Why is a line I didn't change marked as changed?

Most likely the line endings differ: the line break type (Windows versus Unix) or trailing spaces are different. You can't see these, but the algorithm treats them as content. Make the endings consistent, or use 'Compare by word' to see the real edits.

FAQ: Which mode should I choose?

Use line mode to locate which lines changed, for example when comparing two versions of a config file, a log or a checklist. Use word mode to see which words changed inside a sentence, for example when proofreading an article or reviewing a contract revision. A good routine is to look at lines first for the big picture, then switch to words for detail.

FAQ: Does 'Show differences only' change the comparison?

No. It only hides the unchanged segments from the display. The underlying result is the same, and unticking the box shows everything again.

FAQ: Can I compare files, images or Word documents?

No. The tool compares plain text pasted into the two boxes. For Word or PDF documents, copy the content out as plain text first; formatting, comments and images are not compared.

Privacy and processing

The comparison is performed in your browser by the diff library bundled with the page. The tool makes no network requests, your two texts are not uploaded or stored, and reloading the page restores the sample text.