CLI diff tool macOSWindows

Run exact local comparisons from the command line

Use Diff Anything from the CLI with explicit modes, terminal or machine output, Git difftool integration, difference exit codes, and Pro batch reports.

Direct answer

Which command-line features does Diff Anything support?

On Windows, Diff Anything uses its desktop executable with --cli and two source paths, or the arguments Git passes to a diff driver. Single comparisons support auto, text, json, yaml, xml, csv, env, http, api, folder, archive, document, and binary modes (the free CLI runs text and JSON; Pro runs the others); summary, terminal, or JSON output; colour, language, and context controls; and an opt-in difference exit code; --fail-on breaking counts only breaking or unclassified API schema changes. Pro batch manifests support YAML or JSON input, a failOn setting per case, and summary, JSON, JUnit, or SARIF output.

Diff Anything welcome screen with private local comparison sources
Start with files, folders, or pasted content; the comparison stays on the device. View full size

Single comparisons

Every single-comparison option, without implied flags.

Use --mode auto|text|json|yaml|xml|csv|env|http|api|folder|archive|document|binary and --format summary|terminal|json. A terminal defaults to terminal output; redirected stdout defaults to summary.

Use --color auto|always|never, --language LANGUAGE, and --context LINES. Passing --language auto clears the override; context must be non-negative and defaults to three lines.

  • --exit-code: 0 clean, 1 different, 2 invalid input or comparison failure
  • --fail-on breaking: with --mode api, 1 only for breaking or unclassified API schema changes
  • Without --exit-code or --fail-on, a valid changed single comparison exits 0
  • Use -- before paths when a filename begins with a dash
  • --help, --version, and --integration-help are available

PDF layout

Direct PDF layout comparison is desktop; rendered images make it automatable.

CLI document mode compares extracted document content. The rendered-page PDF Visual diff and its per-page match percentage are part of the desktop document workspace, not the direct document CLI result.

For an automated PDF-layout target, render matching reference and candidate pages to images at equal dimensions, compare each pair with Pro --mode binary --format json, and read the image similarity and changed-pixel measurements. A similarity threshold measures the chosen render; it does not prove equal wording, tagging, accessibility, or print behavior.

  • Desktop PDF: choose Visual diff for rendered pages
  • CLI wording: --mode document compares extracted content
  • CLI layout loop: render pages first, then compare each image pair in Pro binary mode

Batch and CI

Batch behavior is explicit and Pro-only.

A batch manifest can be YAML or JSON. Its root can be an object with a comparisons array or a top-level array. Each item accepts name, left, right, an optional supported mode, and failOn: any (the default) or breaking for API schema cases.

Batch output formats are summary, JSON, JUnit, and SARIF, written to stdout or, with --output FILE, to a UTF-8 file. Batch returns 0 when every case passes its failOn check, 1 when a case fails it or could not be compared, and 2 when invocation or manifest loading fails.

  • JUnit records failing cases as test failures and lists API findings with their rule codes
  • SARIF 2.1.0 reports each API finding as its own result: breaking changes under their rule code as errors
  • Desktop profiles and their semantic rules are not batch-manifest options

Free and Pro

Desktop previews and CLI modes have different Free boundaries.

Free desktop use can preview every comparison engine for files up to 5 MiB per side and 10 new comparison sessions per local day; collections show the first 100 items and PDFs show the first 3 page previews. The free CLI supports text and JSON only.

The one-time Pro purchase unlocks every other CLI mode, every batch manifest, larger sources within technical limits, report export, profiles and history, three-way merge, folder synchronization, and trusted preprocessors.

Best for

Where this workflow fits.

  • Reading syntax-highlighted file differences in a terminal
  • Using Diff Anything as a Git difftool or as the diff driver for chosen file types
  • Running repeatable Pro comparison manifests in CI

No accounts, cloud comparison service, analytics, or telemetry.

Relevant capabilities

What Diff Anything brings to the job.

Practical workflow

From setup to a reviewed result.

  1. Enter CLI mode

    Run the installed desktop executable with --cli, any options, and exactly two readable source paths.

  2. Choose mode and output

    Use automatic detection or an explicit supported mode, then select terminal, summary, or JSON output for a person or another program.

  3. Set process behavior

    Add --exit-code when any difference should return 1, or --fail-on breaking for an API schema check; invalid input and comparison errors return 2.

  4. Integrate safely

    Configure a Git difftool or diff driver without --exit-code, or use a Pro batch manifest for summary, JSON, JUnit, or SARIF CI output.

Useful in practice

Direct answers

Questions about CLI diff tool.

Which command-line features does Diff Anything support?

On Windows, Diff Anything uses its desktop executable with --cli and two source paths, or the arguments Git passes to a diff driver. Single comparisons support auto, text, json, yaml, xml, csv, env, http, api, folder, archive, document, and binary modes (the free CLI runs text and JSON; Pro runs the others); summary, terminal, or JSON output; colour, language, and context controls; and an opt-in difference exit code; --fail-on breaking counts only breaking or unclassified API schema changes. Pro batch manifests support YAML or JSON input, a failOn setting per case, and summary, JSON, JUnit, or SARIF output.

Does Diff Anything have a separate image CLI mode?

No. The documented CLI mode list has no image mode. Image files can still be inspected through supported automatic or binary handling, while the purpose-built visual image workspace is a desktop feature.

Does CLI document mode visually compare PDF pages?

No. CLI document mode compares extracted content. For automated layout checks, render corresponding PDF pages to equal-size images first and use Pro binary mode with JSON output; for a direct PDF-to-PDF rendered comparison, use the desktop Visual diff.

Should a Git difftool command use --exit-code?

No. Git already invokes a difftool for a changed pair and expects successful processing, so the documented difftool command omits --exit-code. Leave it out of a diff driver too: Git stops git diff at the first changed file when a diff driver exits with a non-zero status.

Can Diff Anything run as the diff driver for git diff?

Yes, on Windows. Define the driver with git config diff.diff-anything.command and assign it to file types in .gitattributes, for example *.json diff=diff-anything. git diff then uses it for those files; git log -p and git show use it with --ext-diff. On the free plan, a file the plan does not cover is listed as not compared and git diff continues.

Where is the executable installed?

The Microsoft Store version on Windows declares the diff-anything.exe execution alias. The Mac App Store version runs in Apple's App Sandbox, which limits it to files and folders you choose in the app, so command-line use is described for Windows.

Go deeper

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

Read Use Diff Anything from the CLI, Git, and CI
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.

More Diff Anything

Browse every focused tool and workflow.

See all Diff Anything tools