Text & Writing

Text Diff Checker

Diff checker that compares two texts line by line and marks added, removed and unchanged lines side by side or in one list.

Compare Texts

This diff checker compares two versions of a text line by line and labels every line as added, removed or unchanged. Paste the older version into Original Text and the newer one into Modified Text, then press Compare. Counters above the results give the number of lines in each group, and the whole comparison runs in your browser.

How to use the diff checker

  1. Paste the first version into the Original Text box on the left.
  2. Paste the second version into the Modified Text box on the right.
  3. Press Compare. The Differences section opens with three counters: added, removed and unchanged.
  4. Read the Side by Side tab, which shows the two versions in numbered columns with a blank row opposite any line that has no partner. Removed lines are red and added lines are green.
  5. Switch to the Unified tab to see both versions merged into one list marked with plus and minus signs.
  6. Press Clear Both to empty the boxes and hide the results.

How the comparison works

The checker splits each text at its line breaks and finds the longest sequence of lines that appears, in the same order, in both versions. Those lines are unchanged. Every other line in the original is marked removed, and every other line in the modified text is marked added. The method is called longest common subsequence (LCS), and this difference checker applies it to whole lines only.

Worked example with a config file

Original text:

host = localhost
port = 8080
debug = true
timeout = 30

Modified text:

host = localhost
port = 9090
debug = true
timeout = 30
retries = 3

The counters read 2 added, 1 removed and 3 unchanged, and the Unified tab shows:

1    host = localhost
2  + port = 9090
2  - port = 8080
3    debug = true
4    timeout = 30
5  + retries = 3

The edited port line is reported as one removal plus one addition, with the new version listed first. Numbers beside plus lines are positions in the modified text; the others refer to the original.

Ways to compare text and code

Developers use it to find the line that changed between a working and a broken copy of a script or config file. Editors compare two drafts of an article or a contract clause, and anyone keeping a list of URLs or product codes can see which entries were added or dropped.

Lists show the line matching clearly. Compare a shopping list of Milk, Eggs, Bread and Butter, one item per line, with a second list of Milk, Bread, Butter and Coffee. The counters read 1 added, 1 removed and 3 unchanged: Eggs is marked removed, Coffee is marked added, and the three shared items line up opposite each other in the Side by Side tab even though their line numbers have shifted.

To check for differences in text written as long paragraphs, put one sentence on each line in both versions first. A paragraph is one line to the checker, so a single changed word marks the whole paragraph. The same trick helps when you compare an AI draft with your edited version, a process the guide on editing AI content so it sounds human walks through.

To compare JSON, format both versions with the JSON formatter first. Minified JSON sits on a single line, so any edit would mark the whole document as changed. The article on JSON formatters and validators explains why formatting and validating are separate steps. For Markdown files such as a README, compare the source here and check how the final version renders in the Markdown preview. Both tools sit with the other free writing tools.

Limits of this checker

  • Lines are matched exactly. One changed character, a trailing space, different indentation or a change of capital letter marks the whole line as different, and nothing inside the line is highlighted.
  • There is no setting to ignore whitespace or letter case.
  • If only one of the texts ends with a line break, the extra empty line is counted as a difference.
  • The comparison builds a table sized by the line count of one text times the line count of the other, so several thousand lines on each side can make the tab slow or unresponsive.

Frequently Asked Questions

Can the diff checker highlight the exact characters that changed?
No. It works with whole lines, so a line where a single letter differs appears once in red on the original side and once in green on the modified side. To narrow a change down, break long lines into shorter ones before comparing, for example one sentence per line for prose or one item per line for a list.
Is text pasted into the diff checker sent to a server?
No. The comparison is a JavaScript function that runs on the page, and pressing Compare makes no network request, so both texts stay in your browser. The tool does not save them to browser storage either. Clear Both empties the two boxes and hides the results.
Why are two lines that look identical marked as different?
An exact comparison treats invisible characters as real differences. Typical causes are a space at the end of one line, tabs on one side and spaces on the other, or a non-breaking space picked up when copying from a web page or word processor. Removing the stray whitespace in a text editor and comparing again usually clears it.
Can I compare two files or Word documents?
There is no upload button, so the tool only compares what is pasted into the two boxes. For plain-text files such as .txt, .csv, .html or source code, open each file, copy everything and paste it in. For Word documents or PDFs, copy the text out first; bold, fonts and other formatting are dropped in the paste and play no part in the comparison.
Is there a diff checker in VS Code?
Yes. In the VS Code Explorer, right-click the first file and choose Select for Compare, then right-click the second and choose Compare with Selected. VS Code opens a side-by-side view that also marks changes inside a line. This page is handier when the text is not saved in files, such as two versions pasted from email or a web page.