Text Diff/ Line by Line
Highlight line-by-line differences between two texts. Supports code and plain text with configurable context lines. Fully local.
Paste text into both panels above.
Did this tool solve your problem?
What is a text diff tool
A text diff tool uses the LCS (Longest Common Subsequence) algorithm to compare two texts line by line, identifying additions, deletions, and modifications. It's widely used in code reviews, configuration file comparisons, and document version tracking — an essential tool for developers.
Common diff tool use cases
Code review: compare code changes to quickly locate modifications. Configuration management: compare configs across different environments. Document collaboration: view edit history. Data migration: verify data transformation accuracy. Log analysis: compare log outputs at different timestamps.
Code Examples
import { diffLines } from 'diff';
const a = 'foo\nbar\nbaz';
const b = 'foo\nqux\nbaz';
diffLines(a, b).forEach(part => {
const sign = part.added ? '+' :
part.removed ? '-' : ' ';
process.stdout.write(sign + part.value);
});import difflib
a = ['foo\n', 'bar\n', 'baz\n']
b = ['foo\n', 'qux\n', 'baz\n']
# Unified diff (like git diff)
diff = difflib.unified_diff(
a, b,
fromfile='original',
tofile='modified',
n=3, # context lines
)
print(''.join(diff))// github.com/sergi/go-diff
import (
dmp "github.com/sergi/go-diff/
diffmatchpatch"
)
d := dmp.New()
diffs := d.DiffMain(textA, textB, false)
patch := d.PatchMake(textA, diffs)
fmt.Println(d.PatchToText(patch))# Unified diff with 3 context lines diff -U 3 original.txt modified.txt # Git-style diff (no git repo needed) git diff --no-index \ original.txt modified.txt # Side-by-side view diff --side-by-side \ original.txt modified.txt