Text Diff/ Line by Line

Highlight line-by-line differences between two texts. Supports code and plain text with configurable context lines. Fully local.

OriginalA
ModifiedB
Context
Diff

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

JavaScript (jsdiff)
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);
});
Python
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))
Go
// 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))
Shell / CLI
# 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

Frequently Asked Questions

How does the diff algorithm work?
The tool uses the LCS (Longest Common Subsequence) algorithm to compare texts line by line, finding the minimal set of additions and deletions — similar to the algorithm used by git diff.
What do context lines do?
Context lines control how many unchanged lines are shown around each changed section. Setting 0 shows only changed lines; 3 shows 3 lines before and after each change; 'All' shows the complete text.
What types of text are supported?
Any plain text is supported, including code (JavaScript, Python, Go, etc.), config files (JSON, YAML, TOML), Markdown documents, and log files. Comparison is line-based — each line is treated as a whole unit.
Is my content sent to any server?
No. All processing happens entirely in your browser. Your content never leaves your device, making it safe to compare sensitive code or configuration.
How do I copy the diff output?
Click the 'Copy' button in the top-right of the diff panel to copy the unified diff text to your clipboard. The format is compatible with standard git diff (+ for added, - for removed, space for unchanged).
What does the Swap button do?
Clicking Swap A↔B exchanges the Original and Modified panels, letting you view the diff from the opposite direction or quickly reverse the comparison.