Skip to content
86% off$349 $48.86code BF2026

Guides

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

MethodWhat you needViewBest for
diffNothing, it's built inUnified or side-by-side text in TerminalQuick checks, scripts, folders
git diff --no-indexCommand Line Tools (free)Colored unified diff, word-level optionReadable output, changed words
FileMergeFull Xcode (free, large download)Side-by-side windowA graphical view at no cost
Bytepliers Text DiffMacSuite license, or the 7-day trialUnified or side by side, character or word highlightsPasted snippets, patches, JSON and lists

Compare files with diff in Terminal

diff ships with macOS, so you don't need to install anything.

  1. Open Terminal (Applications ▸ Utilities).
  2. Type cd , drag the folder that holds your files onto the Terminal window, and press Return.
  3. Run the comparison:
bash
diff -u old.txt new.txt

This 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:

bash
diff -q old.txt new.txt

Reports only whether the files differ, without details.

bash
diff -y -W 160 old.txt new.txt

Shows 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.

bash
diff -rq folder-a folder-b

Compares 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.

bash
git diff --no-index old.txt new.txt

If 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:

bash
xcode-select --install

Useful options:

bash
git diff --no-index --word-diff old.txt new.txt

Marks changed words inline as [-removed-]{+added+} instead of showing whole lines.

bash
git diff --no-index --color-words old.txt new.txt

Shows the same word-level changes using color instead of brackets.

bash
git diff --no-index --stat old.txt new.txt

Prints 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.

  1. Install Xcode from the Mac App Store.
  2. In Terminal, run:
bash
opendiff old.txt new.txt

FileMerge 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.

  1. 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".
  2. Paste or drop the first text or file into the Original pane.
  3. Paste or drop the second into the Changed pane.
  4. Read the result under Differences. It shows Unified by default. Switch to Side by Side for two columns.
  5. 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".
Text Diff in Side by Side layout comparing production.yaml and staging.yaml with changed characters highlighted

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 .txt or 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 diff for 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 -rq for 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 ignorediffgit diff --no-indexBytepliers Text Diff
Whitespace (all of it, or changes in amount)-w / -b-w / -bIgnore Whitespace (off by default)
Blank lines-B--ignore-blank-linesNo option
Upper/lowercase-iNot availableIgnore Case (off by default)
CRLF vs LF line endingsUse Git or Bytepliers--ignore-cr-at-eolIgnore Line Endings (on by default)

For example, this ignores whitespace and case:

bash
diff -u -w -i old.txt new.txt

And this ignores Windows line endings:

bash
git diff --no-index --ignore-cr-at-eol old.txt new.txt

Export a patch

A patch is a unified diff that a tool can apply to turn the original file into the changed one.

From Terminal:

bash
diff -u old.txt new.txt > changes.patch

Saves the differences to changes.patch.

The next command modifies old.txt in place.

bash
patch old.txt < changes.patch

Applies the patch, so old.txt now matches new.txt. To reverse it, run patch -R old.txt < changes.patch.

From Bytepliers:

  1. In Text Diff, rename the Original and Changed panes so the diff header names the file you'll patch.
  2. Choose Copy Diff (⇧⌘C, Shift-Command-C). This copies a unified diff with 3 lines of context, including the \ No newline at end of file marker where needed.
  3. Save the clipboard to a file in Terminal:
bash
pbpaste > changes.patch

The 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.

  1. Select JSON Compare in the INSPECT group.
  2. Leave the mode on Compare.
  3. Paste or drop the first document into Original and the second into Changed.
  4. 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.
JSON Compare listing added, removed and changed paths between two service configs in the Changes output

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:

bash
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:

  1. Select List Compare in the INSPECT group.
  2. Paste one item per line into List A and List B.
  3. Pick a tab: Only in A, Only in B, In both or Union. Each tab shows its count.
List Compare with two email lists, the Only in A tab selected and counts on each tab

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:

bash
iconv -f UTF-16 -t UTF-8 file.txt > file-utf8.txt

Or 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:

bash
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

To 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.

Every app.
One purchase.