Text Diff Checker
Compare two blocks of text line by line and highlight the differences.
Related Tools
About This Tool
Compares two text inputs and highlights differences at the line, word, or character level. Output uses standard diff conventions: additions in green, deletions in red, unchanged context in neutral. Algorithms include LCS (longest common subsequence) and Myers diff.
Line-level diff suits code review and prose editing; character-level diff better surfaces single-typo or single-character changes in shorter inputs. Whitespace-only differences can be ignored, useful for comparing reformatted code.
The Myers diff algorithm, published by Eugene Myers in 1986, computes the longest common subsequence (LCS) between two sequences in O(ND) time, where N is the input size and D is the edit distance. For small edit distances on large inputs (the common case in version control), this is dramatically faster than the O(N²) naive LCS. Most modern diff tools — git, Mercurial, BSD diff, GNU diffutils — use a Myers variant. Patience diff (used optionally by git) and histogram diff produce more human-readable output by aligning unique landmarks before processing surrounding text.
Granularity matters for comprehension. Line-level diff produces compact output for typical code edits where lines are added, removed, or replaced wholesale. Word-level diff highlights changes within a paragraph of text — useful for editing prose where line-level diff just shows "old paragraph deleted, new paragraph added." Character-level diff is reserved for spot-the-typo situations; on multi-paragraph rewrites, character diff produces visual noise.
A worked example. Input A: "The quick brown fox jumps over the lazy dog." Input B: "The quick red fox jumps over the lazy cat." Word-level diff: "brown" → "red" (deleted/inserted), "dog" → "cat" (deleted/inserted). Character-level diff on the full string would show interleaved changes that take longer to scan. The right granularity matches the edit being made.
Whitespace handling is the most common configuration choice. Reformatting tools (Prettier for JavaScript/TypeScript, gofmt for Go, black for Python) frequently produce diffs that are entirely whitespace — indentation changes, line breaks moved, trailing whitespace trimmed. Reviewing these line-by-line wastes time; the whitespace-ignoring mode reveals whether actual logic changed beneath the reformat. CRLF vs LF line ending differences are handled separately, normalized by default to avoid spurious differences when comparing files from different operating systems.
Limitations: structural diffs (JSON, XML, AST-level) are not provided. A character-level diff of two JSON documents shows superficial differences (key order, whitespace, formatting) when the meaningful diff is at the data structure level. Tools like jd (JSON diff) and difftastic (AST-aware diff) handle this. The general-purpose text diff is suitable for prose, source code without reformatting, and unstructured text; structured data needs structure-aware tools.
The about text and FAQ on this page were drafted with AI assistance and reviewed by a member of the Coherence Daddy team before publishing. See our Content Policy for editorial standards.