Code Difference Comparison Tool
Diff two code or text blocks line by line with unified +/- output and change counts.
Compare two code blocks line by line instantly. Free online code diff tool with unified +/- output and added/removed statistics.
Calculator Inputs
About Code Diff
Diff two code or text blocks line by line with unified +/- output and change counts.
Paste the original and modified text. The tool aligns them with a longest-common-subsequence pass, then walks the alignment emitting context lines, additions (+), and deletions (−) with counts — the same shape as unified diffs from git.
Inputs cap at 500 lines per side to keep the quadratic pass instant in the browser; toggle whitespace-insensitivity for formatting-only comparisons. Everything runs locally.
Where it is used
Reviewing config changes, spotting what broke between deploys, comparing API responses, and checking student submissions.
How to use the Code Diff
- Original Code — enter the value (e.g. const x = 1;).
- Modified Code — enter the value (e.g. const x = 2;).
- Ignore Leading/Trailing Whitespace — enter the value.
- Calculate — press the Calculate button to see the result instantly above.
Formula
Longest-common-subsequence DP over lines → same/add/delete walk.
Examples
Example
Frequently Asked Questions
- How is this different from git diff?
- Same output shape, zero setup: paste two snippets instead of committing. For repos and history, git remains the right tool.
- Why cap at 500 lines?
- LCS is quadratic in input size; the cap keeps large pastes instant instead of freezing the tab. Split bigger files into hunks.
- Does it detect moved blocks?
- Partially — a move shows as a delete plus an add. True move detection needs a fancier (and slower) algorithm.