You have two versions of a document, a config file or some code, and you need to know what changed between them. Comparing them by eye misses changes. A diff tool compares them line by line and highlights every addition and deletion.
Quick answer
Paste both versions into an online diff checker. Removed lines show in
red and added lines in green, and you can switch to word-level or character-level comparison to
see exactly what changed in a line. For files already on your computer, diff on
macOS and Linux or fc on Windows work from the terminal.
1. Use an online diff checker
The SpeedyTools diff checker runs in your browser and never sends the text you paste to a server. Here's how to use it:
- Paste the older version into Original and the newer one into Modified, or load each file with the upload button.
- Read the result. Removed lines start with a minus sign and show in red, added lines start with a plus sign and show in green.
- Change Compare to Words or Characters when one long line changed and you need to see where.
- Copy the result or download it as a .txt file.
It treats everything as plain text, so prose, CSV, JSON, YAML and any programming language all work. It doesn't have ignore-whitespace or ignore-case options, so changed indentation counts as a difference. It does normalise Windows and Unix line endings, so a file saved on another operating system doesn't show every line as changed.
2. Compare files in VS Code
In VS Code's Explorer, right-click the first file and choose Select for Compare,
then right-click the second file and choose Compare with Selected. From a terminal,
code --diff old.txt new.txt does the same thing. VS Code shows the two files side by side
with syntax highlighting, which suits large code files.
3. Compare from the command line
- macOS and Linux.
diff -u old.txt new.txtprints a unified diff. Add-wto ignore whitespace, or-ito ignore case. - Anywhere git is installed.
git diff --no-index old.txt new.txtgives a coloured diff, even outside a repository. Add--word-difffor word-level changes. - Windows. Run
fc old.txt new.txtin Command Prompt, orCompare-Object (Get-Content old.txt) (Get-Content new.txt)in PowerShell.
Use the command line when you need a patch for git apply or patch. The online
tool's output is a readable change list without the headers a patch file needs.
4. Compare Word documents
For .docx files, Microsoft Word's Review > Compare > Compare builds a third document with every change shown as tracked changes, including formatting changes. To compare only the words, copy the text from each document into a diff checker.
Reading a diff
- A whole block marked removed and added again usually means its indentation or line endings changed, not its content.
- The last line marked as changed often means one file ends with a newline and the other doesn't.
- Moved paragraphs show as a deletion in one place and an addition in another. Line diffs don't detect moves.