テキスト比較 (Diff)
New2つのコードやテキストの差分をハイライト表示する比較ツール。
1行
1行
+0 追加-0 削除1 変更なし計 1行
差分結果
| 1 | 1 |
このツールについて
A diff is a comparison between two versions of a text that shows exactly what was added, removed, or unchanged. Diffs are fundamental to version control systems like Git (git diff), code review, documentation management, and any situation where you need to understand what changed between two texts. This tool compares two text blocks line by line, highlights added lines in green and removed lines in red, and shows the unchanged context. Use it to compare configuration files, code snippets, JSON blobs, SQL queries, or any two plain-text inputs.
実践エンジニアリングガイド
Git Diffの仕組み:Myers diffアルゴリズムとテキスト変更追跡の数理
最短編集スクリプト(SES)、最長共通部分列(LCS)、1986年Eugene Myersアルゴリズムの動作グラフ、3-Wayマージ衝突解決、およびブラウザ差分エンジンの最適化を解説します。
使い方
- 1Paste the original (older) text into the left panel.
- 2Paste the modified (newer) text into the right panel.
- 3Click "Compare" — differences are highlighted immediately.
- 4Green lines (+) were added in the new version; red lines (-) were removed.
よくある質問 (FAQ)
- How does the diff algorithm work?
- This tool uses a longest-common-subsequence (LCS) algorithm—the same approach used by the Unix diff utility and Git. It finds the largest set of lines common to both inputs, then marks everything not in that set as either added (in the right text only) or removed (in the left text only).
- What do the colors mean?
- Green lines (prefixed with +) appear only in the right/new text and were added. Red lines (prefixed with -) appear only in the left/old text and were removed. Uncolored lines are present in both texts and are unchanged.
- Is the comparison case-sensitive?
- Yes, by default. A line with a capital letter is treated as different from the same line in lowercase. The comparison is also whitespace-sensitive: a trailing space makes two otherwise identical lines different.
- Can I compare code files?
- Yes—paste the file contents into each panel. The diff operates on plain text, so it works for any language: JavaScript, Python, JSON, YAML, SQL, HTML, or prose. For binary files (images, PDFs), a text diff is not meaningful.