Diff Checker: Compare Two Texts Online
Paste two versions of a text, code or file and see exactly what changed: removed and added lines, and the changed words inside them. Side by side or unified, with options to ignore case and white space. Everything runs in your browser.
How to use this diff checker
- Paste the two versions: the old text into Original text and the new one into Changed text. You can also click Open file or drop a text file (.txt, .csv, .json, .xml, .md, .log, source code) onto a box. The result updates as you type.
- Read the result: red lines were removed, green lines were added. When a line was changed, the exact words that differ are marked in a stronger color. Line numbers on each side show where the change is in each text.
- Move between changes: Next change and Previous jump from one difference to the next. With Only changes ticked, long runs of equal lines are folded; click the bar to show them.
- Choose the view: Side by side puts the two versions next to each other. Unified shows one column like
git diff, which is easier to read on a phone. - Hide differences that do not matter: tick Ignore white space (indentation, tabs, double spaces) or Ignore case. For JSON, click Format JSON so key order and indentation no longer count.
- Save or share: Copy patch or Download .diff gives the result in the standard unified diff format.
How the comparison works
The tool looks for the longest common subsequence of lines: the largest set of lines that appear in both texts in the same order. Every other line is either removed from the original or added in the changed text. It uses the Myers diff algorithm, the same one Git uses by default, so the result is the smallest possible list of changes.
When a removed line and an added line sit at the same place, they are shown as one changed line, and the same method runs again on the words (or characters) of that pair. That is how a single changed number in a long line is marked, instead of the whole line. If the two lines have almost nothing in common, they are shown as a plain removal and addition.
Words mode is best for prose and code. Characters mode finds a single wrong letter, a missing comma or a different kind of space. Chinese and Japanese text is compared character by character in both modes, because it has no spaces between words.
Reading a unified diff (patch)
This is what Copy patch gives you for the sample texts. It is the same format as git diff and diff -u:
--- original +++ changed @@ -1,10 +1,11 @@ # Release checklist -- Update the version number in package.json -- Run the tests: npm test +- Update the version number in package.json and CHANGELOG.md +- Run all tests: npm test - Build the app with npm run build +- Check the build on a phone - Upload the files to the server - Clear the CDN cache -- Tell the team in the chat +- Post the release notes in the team chat -Owner: Anna +Owner: Ben
| Line starts with | Meaning |
|---|---|
--- / +++ | Names of the original and the changed file |
@@ -1,10 +1,11 @@ | A block (hunk): in the original it starts at line 1 and covers 10 lines; in the changed text it starts at line 1 and covers 11 lines |
- | Line removed from the original |
+ | Line added in the changed text |
| a space | Unchanged line, shown as context (3 lines around each change) |
To apply a saved patch to the original file, use git apply changes.diff in a Git project, or patch original.txt < changes.diff on Linux and macOS.
Compare files on the command line
| System | Command | Notes |
|---|---|---|
| Git (any system) | git diff --no-index a.txt b.txt | Works outside a repository too. Add --word-diff for word changes |
| Linux / macOS | diff -u a.txt b.txt | Unified format. -w ignores white space, -i ignores case |
| Linux / macOS | diff -y a.txt b.txt | Side by side in the terminal |
| Windows (cmd) | fc a.txt b.txt | /c ignores case, /w compresses white space |
| Windows (PowerShell) | Compare-Object (Get-Content a.txt) (Get-Content b.txt) | <= only in the first file, => only in the second |
| VS Code | code --diff a.txt b.txt | Opens the built-in side-by-side diff editor |
To check that two large or binary files are exactly the same, comparing their SHA-256 checksums is faster than a line diff.
Frequently asked questions
How do I compare two texts online?
Paste the old version into Original text and the new version into Changed text. The differences appear at once: removed lines in red, added lines in green, and inside a changed line the exact words that changed are marked. Use Next change to jump from one difference to the next.
Is my text uploaded to a server?
No. The comparison runs in your browser with JavaScript. Your texts and files are never uploaded or saved, so you can compare contracts, source code, configuration files or logs that contain private data.
Can I ignore white space or upper and lower case?
Yes. Tick Ignore white space to treat lines as equal when they differ only in spaces, tabs or indentation, and Ignore case to treat A and a as the same. Different line endings (Windows CRLF and Unix LF) are always ignored.
Why does a line show as changed when it looks the same?
The two lines differ by a character you cannot see: a space at the end, a tab instead of spaces, a non-breaking space, or a curly quote instead of a straight one. Switch Highlight to Characters to see exactly where, or tick Ignore white space if the spaces do not matter.
How do I compare two JSON files?
Paste both JSON texts and click Format JSON. Both sides are formatted the same way with sorted keys, so only real differences in values remain. Without this step, a different key order or indentation makes almost every line look changed.
What is a unified diff or patch?
A unified diff is the standard text format for differences, used by git diff, diff -u and code reviews. Lines that start with - were removed, lines with + were added, and lines with a space are unchanged context. A header like @@ -3,4 +3,5 @@ says where each block starts. Copy patch gives you this format, and git apply or patch can apply it to the original file.
Can I compare Word or PDF documents?
This tool compares plain text. Open the Word or PDF document, copy the text and paste it into each box. Formatting such as bold or fonts is not compared, only the words. Text files like .txt, .csv, .json, .xml, .md, .log and source code can be opened directly with Open file.