Skip to content
Latchkey

wdiff: Word-Level Diff Between Files

wdiff compares two files word by word and marks inserted and deleted words inline rather than replacing whole lines.

For prose, docs, or files with very long lines, line diffs are unreadable. wdiff shows exactly which words changed, which is far clearer for text review.

What it does

wdiff runs diff under the hood but reports differences at word granularity. Deleted words are wrapped in [- -] and inserted words in {+ +}, so a one-word edit shows as a one-word change instead of a whole rewritten line. Exit status follows diff (0 same, 1 differ).

Common usage

Terminal
wdiff old.md new.md
# terse: only show the changed words
wdiff -3 old.md new.md
# statistics on words added/deleted
wdiff -s old.md new.md

Options

FlagWhat it does
-3Show only lines from the third (changed) group
-sPrint statistics about the comparison
-iIgnore case
-w / -xSet the string that begins/ends a deletion
-y / -zSet the string that begins/ends an insertion

In CI

Use wdiff to check documentation or generated text where line-level diffs produce noise. Pipe it into colordiff-style rendering or set custom -y/-z markers so the CI log clearly shows word-level edits in changelogs or generated docs.

Common errors in CI

"wdiff: command not found" means the wdiff package is missing. Garbled markers in a log usually mean a downstream tool re-wrapped the [- -] / {+ +} sequences; set explicit -w/-x/-y/-z delimiters. wdiff loads both files into memory, so it can be slow or memory-hungry on very large inputs; prefer diff there.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →