Skip to main content
Back to all tools

Text & File Diff

Compare two texts or files line-by-line using an LCS-based diff algorithm.

Frequently Asked Questions

What is a text diff?

A diff (short for difference) compares two texts and highlights what was added, removed, or changed. It's the same concept used by Git for code reviews. Tip: use diff to verify config file changes, compare API responses, or review content edits before publishing.

What is the difference between unified and side-by-side diff?

Unified diff shows both versions in a single column with + and - prefixes for added/removed lines. Side-by-side diff shows the original and modified text in parallel columns. Tip: side-by-side is better for reviewing small changes; unified is better for long texts where context matters.

How does diffing work internally?

Most diff algorithms (like Myers' algorithm used by Git) find the longest common subsequence (LCS) between two texts, then identify insertions and deletions. The result is the minimum set of edits needed to transform one text into the other.

Can I diff JSON or code files?

Yes, paste any text — JSON, code, config files, or prose. For JSON, format/prettify both inputs first so the diff shows meaningful structural changes rather than whitespace differences. Tip: for semantic JSON diffing (ignoring key order), sort the keys before comparing.

How do I use diff in Git?

git diff shows unstaged changes, git diff --staged shows staged changes, git diff main..feature compares branches. Use git diff --word-diff for inline word-level diffs. Tip: configure a visual diff tool with git difftool for complex reviews.