Diff Anything Product manual

Use Diff Anything from the CLI, Git, and CI

Run repeatable comparisons, read highlighted terminal output, interpret exit codes, integrate with Git, and publish machine-readable CI results.

Automation13 min read8 sections

Find the installed executable

The desktop binary uses --cli for command-line operation so an ordinary launch remains graphical. A Microsoft Store installation declares the diff-anything.exe execution alias; Windows users can run it when that alias is enabled in App execution aliases.

The Mac App Store version runs in Apple's App Sandbox, which limits it to files and folders you choose in the app. This guide therefore covers command-line, Git, and CI use with the Windows version.

  • Windows: diff-anything.exe --cli left.json right.json
  • Check the installed version: diff-anything.exe --cli --version

Enter explicit CLI mode

Provide two source paths and optionally choose --mode auto|text|json|yaml|xml|csv|env|http|api|folder|archive|document|binary, --format summary|terminal|json, and --exit-code. Saved desktop profiles are not CLI options.

An interactive terminal defaults to the highlighted terminal view; redirected output defaults to the concise summary. Use --color auto|always|never, --language for an explicit highlighting language, and --context to control unchanged lines around terminal hunks.

CLI document mode compares extracted content; the rendered-page PDF Visual diff is a desktop feature. For automated layout checks, render corresponding PDF pages to equal-size images, compare each pair with Pro binary mode, and read its image metrics from JSON.

Free CLI use is limited to text and JSON, files up to 5 MiB per side, and 10 new comparison sessions per local calendar day. Specialist modes and all batch manifests require Pro.

  • Terminal: diff-anything --cli --format terminal --color auto left.ts right.ts
  • JSON: diff-anything --cli --format json --mode json left.json right.json
  • Rendered page image: diff-anything --cli --mode binary --format json reference.png candidate.png
  • Use absolute or workflow-stable paths in automation.

Interpret exit codes

For a single comparison, add --exit-code when automation needs differences to affect the process result. Without it, a valid single comparison returns zero even when changes are found.

For an API schema check, use --mode api --fail-on breaking instead: identical or equivalent schemas pass, non-breaking changes are allowed, and the process returns 1 only for breaking changes or changes the rules could not classify.

Batch mode returns zero when every case passes its failOn check, one when a case fails it or could not be compared, and two when the batch cannot be invoked or its manifest cannot be read or parsed.

  • Single with --exit-code: 0 clean, 1 differences, 2 invalid invocation, unreadable input, or comparison failure.
  • Single with --mode api --fail-on breaking: 1 only for breaking or unclassified API changes.
  • Batch: 0 every case passes, 1 a case fails its failOn check or could not be compared, 2 manifest or invocation failure.

Choose output for the consumer

The terminal format gives a person a Unicode-safe, syntax-highlighted diff with line numbers and compact hunks. The concise summary suits ordinary logs, while JSON preserves structured results for another tool.

Batch workflows accept YAML or JSON manifests and can emit summary, JSON, JUnit, or SARIF. JUnit fits test-report surfaces; SARIF fits code-scanning and static-analysis surfaces that understand the standard. Keep diagnostic messages separate from machine-readable output so parsers receive valid documents.

Configure Git difftool

Register Diff Anything as a Git diff tool and pass Git's LOCAL and REMOTE paths into explicit CLI mode. Do not add --exit-code to the difftool command: Git expects the tool to process a changed pair successfully.

Git creates temporary files for some comparisons, so review or edit through the workflow supported by the selected mode rather than assuming a temporary source should be retained.

  • git config --global diff.tool diff-anything
  • git config --global difftool.diff-anything.cmd 'diff-anything.exe --cli "$LOCAL" "$REMOTE"'

Use Diff Anything for git diff

To have git diff itself use Diff Anything, define it as a diff driver and assign it to file types in the repository's .gitattributes file. Git runs the driver only for the files assigned to it, names them by their repository paths, and shows mode changes and renames the way its own diff does.

git diff uses the driver for the assigned files; git log -p and git show use it with --ext-diff. Leave --exit-code out of a diff driver, because Git stops at the first changed file when a driver exits with a non-zero status. On the free plan, a file the plan does not cover is listed as not compared and git diff continues with the rest.

  • git config --global diff.diff-anything.command 'diff-anything --cli --format terminal --color auto'
  • .gitattributes: *.json diff=diff-anything
  • .gitattributes: *.yaml diff=diff-anything
  • diff-anything --cli --integration-help prints this configuration

Run batch manifests

A Pro batch manifest can be a YAML or JSON object with a comparisons array, or a top-level array of comparisons. Each item supports name, left, right, an optional mode, failOn (any or breaking), and warningsAsDifferences; desktop profile rules are not batch-manifest fields, and a misspelt key is reported as an error.

Use --format junit or --format sarif for established review surfaces, or --format json for the detailed result. Write the report with --output FILE, which writes UTF-8; in Windows PowerShell 5.1, redirecting with > writes UTF-16, which many CI tools reject. For API cases with failOn: breaking, JUnit lists the breaking changes with their rule codes and SARIF reports each finding under its rule code.

  • Manifest item: { "name": "API schema", "left": "baseline/openapi.json", "right": "build/openapi.json", "mode": "api", "failOn": "breaking" }
  • JUnit file: diff-anything --cli --batch comparisons.json --format junit --output report.xml
  • SARIF file: diff-anything --cli --batch comparisons.json --format sarif --output report.sarif
Diff Anything private local comparison start screen
Desktop, CLI, Git, and CI use the same local comparison model; the automation surface changes, not the privacy boundary.

Debug automation failures

Reproduce the exact paths, mode, format, and exit-code option locally. Check whether the process can read both sources and whether the shell can create any redirected output file.

CLI comparisons use their built-in default options; they do not load desktop profiles. When results differ by machine, inspect source bytes, line endings, paths, and app version before changing expectations.

Free & Pro: what’s included

Available on the Mac App Store and Microsoft Store. Free desktop use lets you try every comparison engine for files up to 5 MiB per side and 10 new comparison sessions per local day; collection previews show the first 100 items and PDF previews show the first 3 pages. The free CLI supports text and JSON. A one-time Pro purchase removes the preview and session limits and unlocks larger sources within technical limits, saved profiles and history, report export, three-way merge, folder synchronization, batch manifests, trusted preprocessors, and every CLI mode.