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 read7 sectionsLast reviewed August 2026

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 macOS app bundle does not add a command to PATH. Invoke /Applications/Diff Anything.app/Contents/MacOS/diff-anything directly, or create and maintain your own PATH entry outside the app.

  • Windows: diff-anything.exe --cli left.json right.json
  • macOS: /Applications/Diff Anything.app/Contents/MacOS/diff-anything --cli left.json right.json

Enter explicit CLI mode

Provide exactly 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.

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

Batch mode always returns zero only when every comparison is clean, one when any comparison changed or any individual case failed, 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.
  • Batch: 0 all clean, 1 changed or failed cases, 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.

  • Both platforms: git config --global diff.tool diff-anything
  • Windows: git config --global difftool.diff-anything.cmd 'diff-anything.exe --cli "$LOCAL" "$REMOTE"'
  • macOS: git config --global difftool.diff-anything.cmd '"/Applications/Diff Anything.app/Contents/MacOS/diff-anything" --cli "$LOCAL" "$REMOTE"'

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 only name, left, right, and an optional mode; desktop profile rules and expected settings are not batch-manifest fields.

Use --format junit or --format sarif for established review surfaces, or --format json for the detailed result. Output is written to stdout; redirect it in the shell when a report file is needed.

  • Manifest item: { "name": "API schema", "left": "baseline/openapi.json", "right": "build/openapi.json", "mode": "api" }
  • JUnit file: diff-anything --cli --batch comparisons.json --format junit > report.xml
  • SARIF file: diff-anything --cli --batch comparisons.json --format sarif > 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.