仕組み
The underlying algorithm computes a longest common subsequence between the two inputs, then derives the shortest edit script from it — the minimum set of insertions and deletions that turns one text into the other. Running it at line granularity first is what makes the output readable: a paragraph that was reflowed produces one changed line rather than two hundred changed characters. Changes are classified as equal, inserted, deleted or replaced, and the counts of each are summarised so you can see the scale of an edit before reading it.
Intra-line highlighting is a second pass. When a line is classified as replaced, the old and new versions of that line are themselves diffed at word granularity, and the differing spans are emphasised inside the line. Without this, a single changed character in a long line marks the entire line as changed and tells you nothing. With it, the edit is visible immediately. The same pass is what makes a config change reviewable: a line where one port number changed shows the two numbers highlighted and nothing else.
Granularity is a real choice, not a cosmetic one. Line diffing is right for source code and configuration, where line structure carries meaning. Word diffing handles prose that has been reflowed, because the line breaks are noise. Character diffing is for the cases where a single byte matters — a hash, a key, an encoded blob — and is the only setting under which a one-character change in a long token is visible at all. Switching granularity re-runs the comparison without needing the input again.
Ignoring case and whitespace is a normalisation applied before comparison rather than after, so the two texts are canonicalised and then diffed. That is what makes a reformatted file show no changes and a genuine edit show up clearly. The trade is that the highlighted output shows the normalised text, so a change that consists only of capitalisation will appear as no change at all. Turn the options off when the whitespace or the case is the thing you are checking.
主な利用シーン
- Compare two versions of a config file to find what changed between environments.
- Check whether two API responses differ, and if so exactly where.
- Verify that a formatter or transpiler changed nothing semantically in a file.
- Compare two long tokens or keys character by character to find a typo.
- Review a list of values that was edited by hand to confirm only the intended entries changed.
- Produce a unified diff to paste into a code review or a bug report.
最終更新: 2026-10-14 — 本文は英語で表示されます(UI は翻訳済み)。