Text Diff on Mac: Compare Two Files with diff, Git or an App
Run a text diff on a Mac with diff, git diff --no-index or FileMerge, then get side-by-side views, ignore options, patch export and JSON compare.
GuideUpdated 8 min read
On this page
The fastest way to run a text diff on a Mac is in Terminal: diff -u old.txt new.txt. Lines starting with - exist only in the first file, and lines starting with + exist only in the second. For a side-by-side window, run opendiff old.txt new.txt to open FileMerge (this needs Xcode), or paste both texts into a diff tool such as Text Diff in Bytepliers.
Which text diff method to use on a Mac
| Method | What you need | View | Best for |
|---|---|---|---|
diff | Nothing, it's built in | Unified or side-by-side text in Terminal | Quick checks, scripts, folders |
git diff --no-index | Command Line Tools (free) | Colored unified diff, word-level option | Readable output, changed words |
| FileMerge | Full Xcode (free, large download) | Side-by-side window | A graphical view at no cost |
| Bytepliers Text Diff | MacSuite license, or the 7-day trial | Unified or side by side, character or word highlights | Pasted snippets, patches, JSON and lists |
Compare files with diff in Terminal
diff ships with macOS, so you don't need to install anything.
- Open Terminal (Applications ▸ Utilities).
- Type
cd, drag the folder that holds your files onto the Terminal window, and press Return. - Run the comparison:
diff -u old.txt new.txtThis prints a unified diff. The first two lines (--- and +++) name the files. Each block starts with a line like @@ -12,4 +12,5 @@, which means "4 lines starting at line 12 in the old file, 5 lines starting at line 12 in the new one." Unchanged context lines start with a space.
These are the flags you'll use most often:
diff -q old.txt new.txtReports only whether the files differ, without details.
diff -y -W 160 old.txt new.txtShows the files side by side in 160 columns. A | marks a changed line, < marks a line that exists only on the left, and > marks a line that exists only on the right.
diff -rq folder-a folder-bCompares two folders and lists the files that differ or that exist on only one side.
diff exits with status 0 when the files match, 1 when they differ and 2 on an error such as a missing file. That makes it easy to use in scripts.
diff doesn't highlight the changed characters within a line. If one character changes in a long line, the whole line shows as removed and added again.
Use git diff without a repository
Git can compare any two files, even outside a repository. Its output is colored, and it can mark changes word by word.
git diff --no-index old.txt new.txtIf Git isn't installed, macOS offers to install the Command Line Tools the first time you type git. You can also start that install yourself:
xcode-select --installUseful options:
git diff --no-index --word-diff old.txt new.txtMarks changed words inline as [-removed-]{+added+} instead of showing whole lines.
git diff --no-index --color-words old.txt new.txtShows the same word-level changes using color instead of brackets.
git diff --no-index --stat old.txt new.txtPrints only a summary of how many lines changed.
With --no-index, Git exits with status 1 when the files differ, so a chain like git diff --no-index a b && next-command stops when the files differ. Git has no option to ignore case.
Use FileMerge (comes with Xcode)
FileMerge is Apple's graphical diff and merge app. It's free, but it only comes with the full Xcode app. The Command Line Tools on their own don't include it.
- Install Xcode from the Mac App Store.
- In Terminal, run:
opendiff old.txt new.txtFileMerge opens with the two files side by side. You can also open it from Xcode with Xcode ▸ Open Developer Tool ▸ FileMerge and choose the files there. The trade-off is size: Xcode is a large download if all you want is a file comparison.
Compare two files side by side in Bytepliers
Bytepliers is our set of offline developer tools for Mac. Its Text Diff tool helps most when the text is on your clipboard rather than in files, or when you want character-level highlights, ignore toggles and a patch you can copy in one step.
- Open Bytepliers and select Text Diff in the INSPECT group of the sidebar. You can also press ⌘K (Command-K) and type "compare two texts".
- Paste or drop the first text or file into the Original pane.
- Paste or drop the second into the Changed pane.
- Read the result under Differences. It shows Unified by default. Switch to Side by Side for two columns.
- Jump between changes with ⌥⌘↓ (Option-Command-Down Arrow) for Next Change and ⌥⌘↑ for Previous Change. The tool shows where you are, for example "Change 3 of 12".


The status line summarizes the result as "+A −R · N unchanged". When nothing differs, it shows "Identical". In the Options menu, Highlight Changes By switches the inline highlights between Characters (the default) and Words. Swap Texts exchanges the two sides.
There are other ways to load text:
- Open a file into a pane: click into a pane and choose File ▸ Open… (⌘O, Command-O).
- From Finder or the Dock: select two files and choose Open With ▸ Bytepliers, or drag both onto the Dock icon. Two text files opened together go straight into Text Diff. This only works for the file types Bytepliers registers, such as JSON, YAML, XML, CSV, Markdown and SQL. For
.txtor source files, drop them onto the panes instead. - Name the sides: use the pencil icon to rename each pane. The names appear in the diff header.
Text Diff runs on your Mac and sends nothing over the network.
Text Diff has some limits:
- Each side can be up to 10 MB. Use
difffor anything larger. - When the two texts differ heavily, Text Diff switches to approximate blocks and labels the result "Approximate".
- Inline character and word highlights only apply to lines of 10,000 characters or fewer. If you're comparing minified JSON on one long line, format it first or use JSON Compare (below).
- It compares two texts, not folders. Use
diff -rqfor folders.
Ignore whitespace, case or line endings
Reindented code, Windows line endings or changed capitalization can make every line look different. Each tool handles these differently:
| What to ignore | diff | git diff --no-index | Bytepliers Text Diff |
|---|---|---|---|
| Whitespace (all of it, or changes in amount) | -w / -b | -w / -b | Ignore Whitespace (off by default) |
| Blank lines | -B | --ignore-blank-lines | No option |
| Upper/lowercase | -i | Not available | Ignore Case (off by default) |
| CRLF vs LF line endings | Use Git or Bytepliers | --ignore-cr-at-eol | Ignore Line Endings (on by default) |
For example, this ignores whitespace and case:
diff -u -w -i old.txt new.txtAnd this ignores Windows line endings:
git diff --no-index --ignore-cr-at-eol old.txt new.txtExport a patch
A patch is a unified diff that a tool can apply to turn the original file into the changed one.
From Terminal:
diff -u old.txt new.txt > changes.patchSaves the differences to changes.patch.
The next command modifies old.txt in place.
patch old.txt < changes.patchApplies the patch, so old.txt now matches new.txt. To reverse it, run patch -R old.txt < changes.patch.
From Bytepliers:
- In Text Diff, rename the Original and Changed panes so the diff header names the file you'll patch.
- Choose Copy Diff (⇧⌘C, Shift-Command-C). This copies a unified diff with 3 lines of context, including the
\ No newline at end of filemarker where needed. - Save the clipboard to a file in Terminal:
pbpaste > changes.patchThe result works with patch and git apply.
Compare two JSON files by structure
A line diff counts reordered keys or different indentation as changes, even when the data is the same. Bytepliers has a separate JSON Compare tool that ignores key order, whitespace and number formatting.
- Select JSON Compare in the INSPECT group.
- Leave the mode on Compare.
- Paste or drop the first document into Original and the second into Changed.
- Choose an Output:
- Changes (default): a list of paths marked
+added,−removed and~changed, with old → new values. - JSON Patch: the difference as an RFC 6902 patch.
- Merge Patch: the difference as an RFC 7386 merge patch.
- Changes (default): a list of paths marked


When both documents hold the same data, the status says it's the same JSON. Otherwise it shows the number of changes. Arrays are compared by position, so inserting one item early in an array can make the items after it show as changed.
To apply a patch, switch to Apply Patch, paste the Document and the Patch, and read the Result. A patch that is an array is applied as a JSON Patch, and one that is an object is applied as a Merge Patch.
If you'd rather use a line diff, format both files with sorted keys first, then compare them in Text Diff or with diff. Our guide to formatting JSON on Mac covers that.
Compare two lists
To find which items are in one list but not the other, use a set comparison instead of a diff, because line order doesn't matter.
In Terminal, comm compares two sorted lists. Sorting inside the command leaves your files unchanged:
comm -23 <(sort -u a.txt) <(sort -u b.txt)Prints the lines found only in a.txt. Use -13 for lines only in b.txt and -12 for lines in both.
In Bytepliers, use List Compare:
- Select List Compare in the INSPECT group.
- Paste one item per line into List A and List B.
- Pick a tab: Only in A, Only in B, In both or Union. Each tab shows its count.


By default, Trim Whitespace and Ignore Empty Lines are on, and Ignore Case and Sort Results are off. Results keep the order in which items first appear, and each item is listed once. You don't need to sort the lists first.
If it doesn't work
Every line shows as changed. Usually one file has Windows (CRLF) line endings. Use git diff --no-index --ignore-cr-at-eol, or check that Ignore Line Endings is still on in Text Diff. If the file was reindented, add -w or turn on Ignore Whitespace.
diff says "Binary files … differ". One file probably contains null bytes, which is common in UTF-16 text exported from Windows tools. Convert it to UTF-8 first:
iconv -f UTF-16 -t UTF-8 file.txt > file-utf8.txtOr open the file in Bytepliers, which reads UTF-16 with or without a byte-order mark.
opendiff says it requires Xcode. You have only the Command Line Tools, or they're selected instead of Xcode. Once Xcode is in Applications, point the developer tools at it:
sudo xcode-select -s /Applications/Xcode.app/Contents/DeveloperTo go back to the default setting, run sudo xcode-select -r.
git shows "invalid active developer path". The Command Line Tools are missing or broke after a macOS update. Run xcode-select --install.
Text Diff refuses the input or shows "Approximate". A side over 10 MB is refused, so use diff for files that size. "Approximate" means the texts differ too much for a line-by-line match.
JSON Compare reports many changes in one array. Arrays are compared by position, so a single inserted item shifts everything after it. Look at the first change reported in that array.
FAQ
How do I see which words changed, not just which lines? Run git diff --no-index --word-diff old.txt new.txt, or set Highlight Changes By to Words in Bytepliers Text Diff.
Can I compare two folders? Yes. Run diff -rq folder-a folder-b to list the files that differ or exist on only one side. Bytepliers compares texts, not folders.
Do these methods upload my files? No. diff, Git and FileMerge run locally. Text Diff, JSON Compare and List Compare in Bytepliers also work offline.
Bytepliers is part of the MacSuite bundle ($349 one-time as of November 2026, see pricing), and you can try it free for 7 days. For every tool in the app, see the Bytepliers tool reference. For opening, dropping and saving files, see editors, files and value preview.