Diff Two Text Files on Mac: Terminal, FileMerge, Text Diff
Diff two text files on a Mac with diff, git, FileMerge or Bytepliers Text Diff, then copy a unified diff for patch or git apply. Limits included.
GuideUpdated 6 min read
On this page
You have two text files, or two snippets, and you want to see exactly what changed. The question people usually type is "what file comparison tool can I use on macOS?", and the answers they find are often years old. This guide covers what works on current macOS, including what each option cannot do.
Why there is no obvious built-in app
macOS has no Finder feature for comparing files. What it does have is command-line tools: diff and cmp are installed by default. Apple's visual tool, FileMerge, ships with Xcode rather than with the system, so it only exists if Xcode is installed. That gap is why people go looking for a third-party app. Beyond Compare is the name that comes up most often in older forum answers. We have not reviewed it, so check its site for platforms, features and price.
Diff two text files in Terminal
diff is already on your Mac:
diff -u old.txt new.txtLines starting with - exist only in old.txt, lines starting with + exist only in new.txt, and unchanged lines around each change give context. The command only reads the files.
If the files are identical, diff prints nothing. Its exit status is 0 when they match and 1 when they differ, which is how it signals a difference rather than an error.
| Flag | What it does |
|---|---|
-u | Unified output, the format patch and git apply read |
-w | Ignore all whitespace |
-i | Ignore case |
-q | Only say whether the files differ |
To save the diff:
diff -u old.txt new.txt > change.diffWord-level output with git
If git is installed, it can compare two files that are not in a repository and mark changed words instead of whole lines:
git diff --no-index --word-diff old.txt new.txt--no-index tells git to compare plain files, and --word-diff marks the changed words inside each line.
Compare two folders or binary files
For folders, use diff recursively:
diff -rq folder-a folder-b-r walks into subfolders and -q lists only which files differ or exist on one side. Drop -q and add -u to see line-level changes too.
For binary files, diff -u is the wrong tool. Use cmp, also built in:
cmp old.bin new.binIt prints nothing if the files are identical and reports the position of the first difference if not. It does not show a readable diff.
Compare with FileMerge
FileMerge is Apple's visual comparison tool and comes with Xcode, so Xcode must be installed. Open it from Terminal:
opendiff old.txt new.txtPass two folders instead of two files to compare directories. It is free, but Xcode is a large download if you do not already use it.
Diff two files or snippets in Bytepliers Text Diff
Text Diff is one of the 41 tools in Bytepliers, our developer utilities app. It works offline and needs macOS 14 or later. It suits the common case: two files or two pasted snippets, compared on screen, with a diff you can copy out. It compares text only, not folders or binary files.
Compare two pasted snippets or files
- Open Bytepliers and choose Text Diff in the Inspect group of the sidebar. You can also press ⌘K (Command-K) and type "compare two texts".
- Put your first text in the Original pane and the second in the Changed pane. Use Paste from Clipboard, drop a file onto a pane, or click a pane and press ⌘O (Command-O) to open a file.
- Read the result under Differences. The status line shows
+A −R · N unchanged, or Identical when nothing differs.
The pencil next to each pane title renames it. Those names go into the diff header, so name the panes after the real files.
Open two files from Finder
Select two files and use Open With ▸ Bytepliers, or drop them on the Dock icon. Two text files opened at once land in Text Diff.
This only works for file types Bytepliers registers: JSON, YAML, XML, CSV, Markdown, and the extensions sql, pem, crt, cer, der, ndjson, jsonl, yml, md, jwt and geojson. Plain .txt is not on that list, so drop those files onto the panes or use ⌘O in each pane. Bytepliers registers as an alternate viewer, so it never becomes the default app for any file type.
Choose how differences look
The result is Unified by default. Switch to Side by Side for two columns. The Options menu has the rest:
| Option | What it does | Default |
|---|---|---|
| Highlight Changes By | Marks changes inside a line by Characters or Words | Characters |
| Ignore Whitespace | Treats whitespace differences as no change | Off |
| Ignore Case | Treats upper and lower case as the same | Off |
| Ignore Line Endings | Ignores LF vs CRLF differences | On |
Swap Texts flips Original and Changed. Step through results with Next Change (⌥⌘↓, Option-Command-Down Arrow) and Previous Change (⌥⌘↑). The counter reads like "Change 3 of 12".
Copy a unified diff
Click Copy Diff (⇧⌘C, Command-Shift-C) to copy a unified diff. It includes 3 lines of context around each change and marks a missing final newline with \ No newline at end of file, so patch and git apply can read it.
To save it from the clipboard:
pbpaste > change.diffTo check whether git would accept it without applying anything:
git apply --check change.diffLimits of Text Diff
- 10 MB per side. Beyond that you see "Input is … — the limit for Text Diff is 10 MB."
- Text only: no folders, no binary files.
- Very different inputs fall back to approximate blocks and show "Approximate — inputs differ heavily".
- In-line highlighting only applies to lines up to 10,000 characters.
- Files are read as UTF-8, UTF-16 or UTF-32 with a byte order mark, UTF-16 without one, plain UTF-8, or Windows-1252.
Bytepliers is part of MacSuite ($349 one time, as of November 2026), and each app runs free for 7 days. See the Bytepliers tool reference or the Bytepliers page. If diff and FileMerge already cover your work, you do not need another app.
Which method to pick
| You need | Use |
|---|---|
| A quick check or a script, nothing to install | diff -u |
| Word-level changes in the terminal | git diff --no-index --word-diff |
| Compare two folders | diff -rq, or FileMerge |
| Check two binary files | cmp |
| A visual comparison, Xcode already installed | FileMerge via opendiff |
| Two pasted snippets, whitespace and case toggles, a copied diff | Bytepliers Text Diff |
Checklist before you try again
- Both inputs are text, not binary.
- Each side is under 10 MB if you use Text Diff.
- The Options menu does not hide the difference you are looking for.
- The pane names match the file paths you want in the diff header.
If nothing works
- Text Diff says Identical but the files differ. Open Options. Ignore Line Endings is on by default, and Ignore Whitespace or Ignore Case may be on.
- File too large. Compare that pair with
diff -uin Terminal. - "“name” isn't a text file". Bytepliers detected a binary file. Use
cmp. - Bytepliers is missing from Open With. The file type is not registered. Drop the files onto the panes.
- A license prompt appears. The 7-day trial ended. Choose Enter License… from the app menu.
opendiffdoes nothing. Check that Xcode is installed.
If you still need help with Bytepliers, contact support through the MacSuite support page and include this:
Subject: Text Diff problem on macOS
Bytepliers version: (Help menu or About window)
macOS version:
What I did: opened two files / pasted two snippets
What I expected:
What happened (exact message, if any):
File sizes and types:
Options set (Ignore Whitespace / Case / Line Endings):Common questions
Can I compare text without saving it to files first?
Yes in Bytepliers: paste each snippet into its pane. With diff you normally save each snippet to a file first.
Can Text Diff compare two folders?
No. Use diff -rq folder-a folder-b or FileMerge.
Does the copied diff work with git apply?
It is a unified diff with 3 lines of context, the format patch and git apply read. Run git apply --check first to confirm the header paths match your files.
Why does diff print nothing?
The files are identical. Run echo $? right after: 0 means identical, 1 means different.