Synopsis
# compare two files or two folders (the view is detected)
diffscope <left> <right> [options]
diffscope /base:<left> /mine:<right> # slash-switch diff
diffscope --left <left> --right <right>
# 3-way merge
diffscope /base:B /mine:M /theirs:T /merged:OUT
diffscope --merge --base B --mine M --theirs T -o OUT
diffscope --merge <base> <mine> <theirs> [-o OUT]
diffscope <mine> <theirs> <base> <merged> # four-argument form
# no window: unified diff / merge result, exit codes 0, 1, 2
diffscope --headless <left> <right> > out.diff
diffscope --headless --merge B M T -o OUT
The diffscope command is installed by the Windows installer (in %LOCALAPPDATA%\Programs\DiffScope\resources\bin, added to your PATH) and by the Linux package (/usr/bin/diffscope). It prints to the terminal and returns the exit code of the comparison. With no arguments, DiffScope opens the home screen; diffscope --help prints the built-in summary.
Syntax rules
Slash switches
DiffScope’s Windows-style slash switches take their value after : or =, for example /base:file.txt or /title1="My file". Keywords are not case-sensitive.
When is /something a switch?
Only when the word after the slash is one of DiffScope's keywords, followed by the end of the argument, : or =. Everything else is a path. So C:\a b\c.txt, a Unix-style path such as /c/Users/me/a.txt, /base/dir/file and /tmp/x are all treated as paths.
The keywords are:
base mine theirs merged savetarget left right basename minename theirsname mergedname lefttitle righttitle centertitle outputtitle title1 title2 title3 title4 readonly ro leftreadonly rightreadonly automerge reviewconflicts resolve line oneway saverequired saverequiredonconflicts createunifieddiff origfile modifiedfile outfile reversedpatch diff patchpath patchoriginal patchpatched s ns iu ignoreunimportant filters favorleft favorright qc quickcompare fv fileviewer basereflectedname minereflectedname theirsreflectedname mergedreflectedname help ?
- Values may be wrapped in double quotes; one pair of surrounding quotes is removed.
- A switch that needs a value but has none (
/base) is an error. So is a value on a flag (/readonly:yes). - An argument that is exactly a keyword (
/ro) is always a switch. To pass a file with that name, put it after--or write.\ro.
GNU options
- Long options take values as
--base fileor--base=file. Long option names are not case-sensitive. - Short flags can be grouped (
-wiB), and short values can be attached (-U5,-oout.txt,-o=out.txt). - An unknown option is an error, and DiffScope suggests the closest name (did you mean --ignore-case?).
--ends the options. Everything after it is a path, even-x.txtor/title1:x.
Paths and quoting
- Relative paths are resolved against the current folder.
- On Windows, if a Unix-style drive path such as
/c/Users/me/a.txtdoes not exist as written, DiffScope converts it toC:\Users\me\a.txt. - On Windows, do not end a quoted path with a backslash (
"C:\dir\"): Windows reads\"as an escaped quote. Write"C:\dir". -as one side reads it from standard input, for examplesome-command | diffscope - file.txt.
Positional forms
| Paths | Meaning |
|---|---|
| 2 | <left> <right>: a two-way compare of two files or two folders. |
3, with --merge | <base> <mine> <theirs>: a merge. Give the output with -o. Three paths without --merge are rejected as ambiguous. |
| 4 | <mine> <theirs> <base> <merged>: a merge (left, right, center, output). |
| 1 or 5+ | Rejected. |
Positional paths cannot be mixed with named paths (/base, --mine and so on), and the same path cannot be given twice.
Switch reference
Paths
| Slash | GNU | Meaning |
|---|---|---|
/base:P | --base P | Merge: the common ancestor. With only /mine beside it: the left file of a diff. |
/mine:P | --mine P, --local P | Merge: your version. With only /base: the right file of a diff. |
/theirs:P | --theirs P, --remote P | Merge: the incoming version. |
/merged:P, /savetarget:P | -o P, --output P, --merged P, --out P | Merge: the file to write. Optional in the window (you are asked on save); in headless mode the result goes to stdout without it. |
/left:P | --left P | Diff: the left path. |
/right:P | --right P | Diff: the right path. |
A merge starts when /theirs, /merged or --merge is present; it then needs all of base, mine and theirs. /left /right cannot be mixed with /base /mine /theirs.
Titles
| Slash | GNU | Meaning |
|---|---|---|
/title1:T … /title4:T | --title1 T … --title4 T | Diff: 1 = left, 2 = right (3 and 4 are ignored). Merge: 1 = mine, 2 = theirs, 3 = base, 4 = output. |
/basename:T, /centertitle:T | --base-title T | Base title. For a /base: /mine: diff: the left title. |
/minename:T | --mine-title T | Mine title. For a /base: /mine: diff: the right title. |
/theirsname:T | --theirs-title T | Theirs title. |
/mergedname:T, /outputtitle:T | --merged-title T | Output title. |
/lefttitle:T | --left-title T | Left title (mine in a merge). |
/righttitle:T | --right-title T | Right title (theirs in a merge). |
| – | -L T, --label T | Repeatable, as in GNU diff. Diff: left, then right. Merge: mine, base, theirs. |
An empty value (/title1:) gives an empty title. Titles also label the conflict markers and the --- / +++ lines of headless output.
Modes
| Option | Meaning |
|---|---|
--merge, -m | 3-way merge. |
--diff, -d | Force a two-way compare (cannot be combined with merge paths). |
--headless | Run without a window. See Headless mode. |
--text | Compare two files as text even if they look binary. |
--hex, --binary | Compare two files byte by byte in the hex view. |
--folder | Require two folders (headless mode fails if they are not). |
--table | Compare two files as tables (CSV, TSV, …). .csv, .tsv and .tab files open as tables anyway. |
--image | Compare two images. Two image files open in the image compare anyway. |
Only one view option can be given. Merges are always text, so --hex and --folder are rejected for a merge.
Comparison options
| Option | Meaning |
|---|---|
--ignore-whitespace[=MODE] | MODE is all (default when given without a value), changes, leading-trailing or none. |
-w, --ignore-all-space | Ignore all whitespace. |
-b, --ignore-space-change | Ignore changes in the amount of whitespace. |
--ignore-leading-trailing | Ignore whitespace at the start and end of lines. |
-i, --ignore-case | Ignore case. |
-B, --ignore-blank-lines | Ignore inserted or removed blank lines. |
--compare-eol | Lines that differ only in CRLF vs LF count as different (ignored with -w). |
--granularity=word|char | Highlight changed words or single characters inside changed lines. |
-I RE, --ignore-matching-lines=RE | Ignore changes whose lines all match RE. Repeatable. |
--line-filter=RE | Lines matching RE are unimportant: left out before diffing and shown dimmed. Repeatable. |
--text-filter=RE | The parts of lines matching RE are unimportant. Repeatable. |
--ignore-comments[=LANG] | Comments are unimportant. LANG is auto (by file extension, the default) or one of c, cpp, cs, java, js, ts, go, rust, swift, kotlin, scala, python, shell, powershell, sql, css, scss, ini, yaml, vb, batch, xml, html. |
--prettify[=json|xml] | Re-indent JSON or XML before comparing (auto: by extension; read-only in the window). |
--rules FILE | Comparison rules from a JSON file: presets, line and text filters. -I cannot be combined with --line-filter. |
--diff-algorithm=NAME | myers (default), minimal, patience or histogram; also --minimal, --patience, --histogram. |
--prediff=ID | Run the pre-diff command ID from the preprocess.commands setting on the files it matches before comparing. Headless runs need --settings and a command trusted in the window. |
-U N, --context N, --unified N | Lines of context in headless unified diffs (default 3). |
-R, --reverse, /reversedpatch | Swap the sides of a unified diff. |
Regular expressions use the JavaScript syntax. These options also set the matching controls when a text compare opens.
Folder options
| Option | Meaning |
|---|---|
--compare=MODE | content (default), size, size-mtime or rules. See compare modes. |
--exclude PATTERN | Leave out matching files and folders. Repeat for more patterns. See filter strings and patterns. |
--gitignore, --no-gitignore | Hide or show what the ignore files of a working copy exclude. The window hides them by default; headless runs only with --gitignore. |
--no-recursive | Compare the top level only. |
--all | Headless folder output also lists unchanged entries. |
--sync=MODE [--yes] [--dry-run] | Two folders: print the sync plan for update-right, update-left, update-both, mirror-right or mirror-left; --yes runs it (a mirror deletes permanently here). Exit 0 done or nothing to do, 1 some operations failed, 2 error. |
Merge options
| Option | Meaning |
|---|---|
--diff3 | Add a ||||||| base section to conflict markers (window and headless). See diff3 style. |
/automerge, --automerge | Merge without a window: with no conflicts the result is written to /merged and the exit code is 0; with conflicts the file is left untouched and the exit code is 1. |
/reviewconflicts, --review-conflicts | Like /automerge, but open the merge window when conflicts remain. |
--ws-conflicts=mine|theirs | Headless merges and /automerge: conflicts whose sides differ only in whitespace take that side. |
--resolve-simple | Headless merges and /automerge: resolve conflicts whose two sides changed different words (strict safety rules). |
/iu, --ignore-unimportant | Hide unimportant differences; with /automerge, whitespace-only conflicts take the favoured side. |
/favorleft, /favorright, --favor-left, --favor-right | With /automerge or a headless merge: the conflicts that remain take mine (left) or theirs (right), so the merge is written (exit 0). |
--resolve FILE, /resolve:FILE | Resolve a file that already contains conflict markers (also /merged:FILE alone); saving writes FILE. Headless: exit 0 no conflicts, 1 conflicts, 2 malformed markers. |
Window options
| Option | Meaning |
|---|---|
/line:N, --line N | Open at line N of the right file of a diff, or of the merged output of a merge. |
/oneway, --oneway | Open a diff in the one-pane (inline) view. |
/saverequired, --save-required | Ask to save before closing even when nothing was changed. |
/saverequiredonconflicts, --save-required-on-conflicts | Ask to save while conflicts remain (merges always do). |
--clipboard FILE | Compare FILE with the text on the clipboard. |
/s, --reuse | Open as a tab of the running DiffScope. This process still waits and exits with that tab’s exit code. This is the default (the window.reuse setting). |
/ns, --new-window | A window and process of its own. |
--nowait | With reuse: return as soon as the tab is open (exit 0). |
/basereflectedname:N … /mergedreflectedname:N | The real file names behind temporary files; used to pick the syntax colouring. |
Tables, patches, reports and more
| Option | Meaning |
|---|---|
--table-key=COLS | Match table rows by these key columns (names or 1-based numbers, comma separated) instead of by order. |
--tolerance N | Images: channel differences up to N (0–255) count as equal. |
/diff:PATCH [/patchpath:FOLDER] | Open the patch viewer: the files a .patch or .diff changes in FOLDER (default: the patch’s folder). Also --patch P [--patch-dir D] [--reverse], or a lone .patch / .diff path. |
--headless --patch P [--dry-run] | Apply the patch: exit 0 everything applied, 1 a hunk did not fit (FILE.rej has it) or a file is missing, 2 the patch cannot be read. |
/createunifieddiff /origfile:A /modifiedfile:B [/outfile:P] | Write a unified diff of A → B to P (or stdout) without a window; exit 0 written, 2 error. GNU spelling: --create-unified-diff --left A --right B -O P. |
--report FILE | Write a report of a file or folder comparison to FILE without a window: --report-format=html|txt|csv|xml|json|pdf (default: by extension), --report-layout=side-by-side|unified, --report-context=N|all. |
--changeset [REV | A..B | A...B] | The files a commit or a range of commits changed, as a folder compare, with --staged, --worktree and -C REPO. Headless: list them; exit 0 nothing changed, 1 changes, 2 error. |
--shell-select P, --shell-compare P, --shell-pair P | What the Windows Explorer menu runs. |
Quick compare and filters
| Option | Meaning |
|---|---|
/qc[=size|crc|binary], --quick-compare[=TYPE] | Compare two files or folders without a window and exit with these codes: 1 binary same, 2 rules-based same, 11 binary differences, 13 rules-based differences, 100 error (default type: rules-based). |
/filters="MASKS", --filters=MASKS | Folder filter string: *.c;*.h;-obj\;-*.bak (- excludes, a trailing \ means folders). |
/fv="VIEW", --file-viewer=VIEW | "Text Compare", "Hex Compare", "Folder Compare", "Picture Compare", "Table Compare" or "Text Merge". |
Read-only
| Slash | GNU | Meaning |
|---|---|---|
/leftreadonly | --left-readonly | The left side cannot be edited. |
/rightreadonly | --right-readonly | The right side cannot be edited. |
/readonly, /ro | --readonly, --read-only, -r | Neither side can be edited. |
Settings
DiffScope saves its settings in %APPDATA%\DiffScope\settings.json on Windows and ~/.config/DiffScope/settings.json on Linux. Options given on the command line, such as -w, apply to that comparison only and never change the saved defaults.
| Option | Meaning |
|---|---|
--set KEY=VALUE | Override one setting for this session, for example --set diff.ignoreCase=true. Repeatable. |
--settings FILE | Read and write this settings file instead of the default one. |
--no-settings | Use the defaults only; nothing is read or written. Cannot be combined with --settings. |
Precedence, lowest to highest: defaults, the settings file, --set, explicit options such as -w, then toggles made in the window. --headless never reads settings unless --settings or --set is given, so scripts get the same result on every machine.
Other
| Option | Meaning |
|---|---|
--help, -h, /?, /help | Print the usage summary and exit with 0. |
--version, -v, -V | Print DiffScope and the version (for example DiffScope 1.5.2) and exit with 0. |
--smoke-test | Start the window, run a self-check on built-in samples and exit. |
Headless mode
With --headless, DiffScope compares or merges without a window, prints the result and exits.
Use the diffscope command
The diffscope command prints to the terminal and waits for the result, on Windows and Linux. On Windows, calling DiffScope.exe directly also works, but as a GUI program its output only reaches a file or a pipe (> out.diff, | Out-File).
What it prints
| Input | Output |
|---|---|
| Two text files | A unified diff (---, +++, @@ hunks) on stdout, nothing when identical. If only the encoding or line endings differ: Files A and B differ only in … |
| Two binary files | Binary files A and B differ, both sizes, the number of differing ranges, the first differing offset, and up to 50 ranges with a 16-byte preview of each side. |
| Two folders | A tree of differences: * different, < left only, > right only, ! type mismatch, ? error (and = same with --all), then a summary line. |
Merge with -o | Writes the merged file (conflict markers where needed) and prints Merged cleanly: OUT or Merged with N conflict(s): OUT on stderr. |
Merge without -o | The merged file's content on stdout. |
| Error | diffscope: error: <message> on stderr. |
Merged output keeps the encoding and line endings of the inputs. The output file is written through a temporary file, so a failed run never leaves a half-written result.
Exit codes
| Code | Diff | Merge |
|---|---|---|
| 0 | Identical (or the only differences are ignored by your options) | Merged cleanly |
| 1 | Different | Conflicts left; the file is written with markers |
| 2 | Error: a path is missing, a folder paired with a file, unreadable input | Error; nothing is written |
In the window, a merge exits with 0 only when it was saved with no conflicts left, otherwise 1. A two-way compare window exits with 0 when closed, or 2 if the comparison could not be opened. See Closing and exit codes.
Invalid command lines fail fast
With --headless, a command line DiffScope cannot parse (an unknown option, a missing value, three paths without --merge) prints the error to stderr and exits with 2, so a CI job fails instead of waiting.
Examples for scripts and CI
# Fail the build when generated files drift from what is expected
diffscope --headless -w expected/api.json generated/api.json > drift.diff
case $? in
0) echo "api.json unchanged" ;;
1) echo "api.json changed, see drift.diff"; exit 1 ;;
*) echo "comparison failed"; exit 2 ;;
esac
# Compare two release folders by content, skipping build output
diffscope --headless --folder --exclude node_modules --exclude "*.pdb" release/2.3 release/2.4 > tree.txt
# An HTML report of the same comparison
diffscope --report release-report.html release/2.3 release/2.4
# Try a 3-way merge; keep the result only when it is clean
diffscope --headless --merge --diff3 base.cs mine.cs theirs.cs -o merged.cs
switch ($LASTEXITCODE) {
0 { "merged cleanly" }
1 { "conflicts left in merged.cs" }
default { "merge failed" }
}
# Unified diff with 5 lines of context, ignoring case and blank lines
diffscope --headless -U5 -iB old.txt new.txt > changes.diff
# Paths starting with "-" go after --
diffscope --headless -- -old.txt -new.txt > changes.diff
