How to Compare Two Texts and Find the Difference
Comparing two versions of a text takes only a few seconds, and works the same way for documents, code, data files and lists.
- Paste or type the original text into the Original box, or drag and drop a file onto it (or press Open file).
- Paste the new version into the Changed box, or drop the second file onto it.
- Optionally turn on Ignore whitespace or Ignore case, and choose word or character highlighting.
- Press Find Difference (or Ctrl + Enter). Removed lines are shown in red and added lines in green.
- Switch between Side by side and Unified view, then press Copy diff or Download .diff to save the result.
Reading the Results
The diff checker colors each line by what happened to it, and highlights the exact words or characters that changed inside lines that were edited.
| Color | Meaning |
|---|---|
| − red | The line was removed from, or changed in, the original text. |
| + green | The line was added to, or changed in, the new text. |
| word word | The exact words or characters that were removed or added inside a changed line. |
| plain | The line is the same in both texts. |
How the Diff Algorithm Works
The tool splits both texts into lines and uses the Myers difference algorithm, published by Eugene Myers in 1986 and used by Git and the Unix diff command, to find the shortest edit script: the fewest lines to remove and add to turn the original into the changed text. Lines that are only removed or only added are shown on their own, and a removed line followed by an added line is shown as a changed line. Each changed pair is then compared again word by word (or character by character), so a one-letter typo is highlighted precisely instead of marking the whole line.
The Unified Diff (Patch) Format
Press Copy diff or Download .diff to get the differences in the standard unified diff format. Each change is shown with 3 lines of surrounding context; lines starting with - were removed and lines starting with + were added:
--- Original
+++ Changed
@@ -1,4 +1,4 @@
The quick brown fox
-jumps over the lazy dog.
+leaps over the lazy cat.
It was a sunny day
in the park.
The @@ -1,4 +1,4 @@ header means the change starts at line 1 and covers 4 lines in both the original and the changed text.
Popular Uses
- Writing and editing: see what an editor, colleague or AI assistant changed in an article, essay or contract.
- Programming: compare two versions of source code, a configuration file or a SQL script without opening Git.
- Data: find the rows that differ between two CSV exports, JSON responses or lists.
- IT and operations: compare log files, server settings or command output before and after a change.
- Education: check a student's answer against a model answer, or a translation against the original.
Frequently Asked Questions
What is a diff checker?
A diff checker is a tool that compares two versions of a text, document or file and shows exactly what is different between them. Lines that were removed are highlighted in red, lines that were added are highlighted in green, and the words or characters that changed inside a line are highlighted more strongly, so you can see every change at a glance.
How do I compare two texts online?
Paste the original text into the Original box and the new text into the Changed box, or drag and drop a file onto either box. Then press Find Difference. The differences appear below, side by side or inline, with a count of added and removed lines.
Can I compare files, not just text?
Yes. Drag and drop a text-based file onto either box, or press Open file, to load it. Any plain-text format works, including TXT, CSV, JSON, XML, HTML, CSS, JavaScript, C#, Python, SQL, Markdown, YAML, logs and configuration files, up to 5 MB each. Word and PDF files are not plain text, so copy their text and paste it instead.
What is the difference between side-by-side and unified view?
Side-by-side view shows the original text on the left and the changed text on the right, with matching lines lined up across from each other. Unified (inline) view shows a single column, with each removed line directly above the line that replaced it, which is easier to read on a phone. The tool switches to unified view automatically on small screens, and you can change it at any time.
Can it ignore whitespace and capital letters?
Yes. Turn on Ignore whitespace to treat lines as equal when they only differ in spaces, tabs or indentation, and turn on Ignore case to treat upper-case and lower-case letters as the same. This is useful when comparing code that was reformatted or text that was retyped.
How are the differences found?
The tool uses the Myers difference algorithm, the same approach used by Git and the Unix diff command, to find the smallest set of lines to remove and add to turn the original text into the changed text. Within each changed line, the same algorithm is run again on words or characters to highlight exactly what changed.
Can I save or share the result as a patch?
Yes. Press Copy diff to copy the differences in the standard unified diff (patch) format with 3 lines of context, or Download .diff to save it as a file. The patch format is understood by Git, code review tools and the patch command.
Is my text uploaded or stored?
No. The comparison runs entirely in your browser using JavaScript, so your text and files never leave your device and are not stored anywhere. They are cleared when you close or reload the page, which makes it safe for private documents, contracts and source code.
Does it work on iPhone, iPad and Safari?
Yes. The diff checker works in Safari on Mac, iPhone and iPad, as well as Chrome, Edge, Firefox and Samsung Internet on desktop and mobile. On a phone or tablet, tap Open file to load a file instead of dragging and dropping.
How large can the texts be?
Each side can hold up to 5 MB of text, which is roughly 100,000 lines of code. Very large texts with many differences take a little longer to compare; if two texts are almost completely different, the comparison is simplified so the page stays responsive.