Reference

Command-line reference

Command-line support for automation and integration into existing workflows, on Windows and Linux. DiffScope accepts slash switches, GNU-style options and plain paths, freely mixed. Add --headless to compare or merge without a window.

Applies to DiffScope v1.5.2 Updated Oct 2026

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 file or --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.txt or /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.txt does not exist as written, DiffScope converts it to C:\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 example some-command | diffscope - file.txt.

Positional forms

PathsMeaning
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

SlashGNUMeaning
/base:P--base PMerge: the common ancestor. With only /mine beside it: the left file of a diff.
/mine:P--mine P, --local PMerge: your version. With only /base: the right file of a diff.
/theirs:P--theirs P, --remote PMerge: the incoming version.
/merged:P, /savetarget:P-o P, --output P, --merged P, --out PMerge: 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 PDiff: the left path.
/right:P--right PDiff: 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

SlashGNUMeaning
/title1:T … /title4:T--title1 T … --title4 TDiff: 1 = left, 2 = right (3 and 4 are ignored). Merge: 1 = mine, 2 = theirs, 3 = base, 4 = output.
/basename:T, /centertitle:T--base-title TBase title. For a /base: /mine: diff: the left title.
/minename:T--mine-title TMine title. For a /base: /mine: diff: the right title.
/theirsname:T--theirs-title TTheirs title.
/mergedname:T, /outputtitle:T--merged-title TOutput title.
/lefttitle:T--left-title TLeft title (mine in a merge).
/righttitle:T--right-title TRight title (theirs in a merge).
–-L T, --label TRepeatable, 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

OptionMeaning
--merge, -m3-way merge.
--diff, -dForce a two-way compare (cannot be combined with merge paths).
--headlessRun without a window. See Headless mode.
--textCompare two files as text even if they look binary.
--hex, --binaryCompare two files byte by byte in the hex view.
--folderRequire two folders (headless mode fails if they are not).
--tableCompare two files as tables (CSV, TSV, …). .csv, .tsv and .tab files open as tables anyway.
--imageCompare 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

OptionMeaning
--ignore-whitespace[=MODE]MODE is all (default when given without a value), changes, leading-trailing or none.
-w, --ignore-all-spaceIgnore all whitespace.
-b, --ignore-space-changeIgnore changes in the amount of whitespace.
--ignore-leading-trailingIgnore whitespace at the start and end of lines.
-i, --ignore-caseIgnore case.
-B, --ignore-blank-linesIgnore inserted or removed blank lines.
--compare-eolLines that differ only in CRLF vs LF count as different (ignored with -w).
--granularity=word|charHighlight changed words or single characters inside changed lines.
-I RE, --ignore-matching-lines=REIgnore changes whose lines all match RE. Repeatable.
--line-filter=RELines matching RE are unimportant: left out before diffing and shown dimmed. Repeatable.
--text-filter=REThe 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 FILEComparison rules from a JSON file: presets, line and text filters. -I cannot be combined with --line-filter.
--diff-algorithm=NAMEmyers (default), minimal, patience or histogram; also --minimal, --patience, --histogram.
--prediff=IDRun 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 NLines of context in headless unified diffs (default 3).
-R, --reverse, /reversedpatchSwap 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

OptionMeaning
--compare=MODEcontent (default), size, size-mtime or rules. See compare modes.
--exclude PATTERNLeave out matching files and folders. Repeat for more patterns. See filter strings and patterns.
--gitignore, --no-gitignoreHide or show what the ignore files of a working copy exclude. The window hides them by default; headless runs only with --gitignore.
--no-recursiveCompare the top level only.
--allHeadless 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

OptionMeaning
--diff3Add a ||||||| base section to conflict markers (window and headless). See diff3 style.
/automerge, --automergeMerge 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-conflictsLike /automerge, but open the merge window when conflicts remain.
--ws-conflicts=mine|theirsHeadless merges and /automerge: conflicts whose sides differ only in whitespace take that side.
--resolve-simpleHeadless merges and /automerge: resolve conflicts whose two sides changed different words (strict safety rules).
/iu, --ignore-unimportantHide unimportant differences; with /automerge, whitespace-only conflicts take the favoured side.
/favorleft, /favorright, --favor-left, --favor-rightWith /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:FILEResolve 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

OptionMeaning
/line:N, --line NOpen at line N of the right file of a diff, or of the merged output of a merge.
/oneway, --onewayOpen a diff in the one-pane (inline) view.
/saverequired, --save-requiredAsk to save before closing even when nothing was changed.
/saverequiredonconflicts, --save-required-on-conflictsAsk to save while conflicts remain (merges always do).
--clipboard FILECompare FILE with the text on the clipboard.
/s, --reuseOpen 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-windowA window and process of its own.
--nowaitWith reuse: return as soon as the tab is open (exit 0).
/basereflectedname:N … /mergedreflectedname:NThe real file names behind temporary files; used to pick the syntax colouring.

Tables, patches, reports and more

OptionMeaning
--table-key=COLSMatch table rows by these key columns (names or 1-based numbers, comma separated) instead of by order.
--tolerance NImages: 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 FILEWrite 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 PWhat the Windows Explorer menu runs.

Quick compare and filters

OptionMeaning
/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=MASKSFolder 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

SlashGNUMeaning
/leftreadonly--left-readonlyThe left side cannot be edited.
/rightreadonly--right-readonlyThe right side cannot be edited.
/readonly, /ro--readonly, --read-only, -rNeither 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.

OptionMeaning
--set KEY=VALUEOverride one setting for this session, for example --set diff.ignoreCase=true. Repeatable.
--settings FILERead and write this settings file instead of the default one.
--no-settingsUse 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

OptionMeaning
--help, -h, /?, /helpPrint the usage summary and exit with 0.
--version, -v, -VPrint DiffScope and the version (for example DiffScope 1.5.2) and exit with 0.
--smoke-testStart 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

InputOutput
Two text filesA 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 filesBinary 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 foldersA tree of differences: * different, < left only, > right only, ! type mismatch, ? error (and = same with --all), then a summary line.
Merge with -oWrites the merged file (conflict markers where needed) and prints Merged cleanly: OUT or Merged with N conflict(s): OUT on stderr.
Merge without -oThe merged file's content on stdout.
Errordiffscope: 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

CodeDiffMerge
0Identical (or the only differences are ignored by your options)Merged cleanly
1DifferentConflicts left; the file is written with markers
2Error: a path is missing, a folder paired with a file, unreadable inputError; 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