How diff algorithms compare text
Our diff checker implements the Myers diff algorithm (used by Git) with a patience-mode fallback for structured text. The Myers algorithm finds the shortest edit script between two sequences in O(ND) time, where N is total text length and D is the number of differences. For most file comparisons, this completes in milliseconds. For large files (10,000+ lines), patience mode reduces spurious matches on repeated lines like import statements or closing braces.
The tool also highlights intra-line changes (word-level or character-level diff) so you can spot spelling fixes or variable renames within a modified line. This is powered by a secondary diff pass on each changed line segment, splitting on whitespace and punctuation boundaries.
Real-world diffing workflows
Before refactoring, diff the original and refactored versions to confirm the only changes are structural (renames, extracted functions) — the behavioral output should be identical. This is especially useful when modernizing legacy jQuery code to vanilla JS or React hooks.
When reviewing pull requests, paste the raw diff into this tool and toggle unified/split view to catch non-obvious changes like whitespace-only modifications or accidental semicolon insertion that could introduce ASI bugs. The character-level diff helps spot differences in long hex strings or UUIDs that are easy to miss.