Text Diff Checker — Compare Two Texts

Have two versions of a piece of text and want to know exactly what changed? This tool compares them line by line and highlights every difference. Removed lines are shown in red and added lines are shown in green, so you can quickly see what was changed, added, or deleted. This is useful for comparing two versions of a document, reviewing edits, checking if two config files differ, or proofreading revised content. Paste both texts and click Compare.


Frequently Asked Questions

What is a text diff?

A text diff is a comparison between two versions of a text that highlights what changed. Removed lines appear in red and added lines appear in green. Developers use diff tools constantly to review code changes in version control systems like Git.

What can I use a text diff tool for?

Comparing two versions of a document, proofreading edited writing, comparing config files, reviewing contract revisions, or checking if a file was modified are all common uses. Any time you need to know exactly what changed between two pieces of text, this tool helps.

Does this tool compare characters or whole lines?

This tool compares line by line. A line that differs between the two versions appears as one removed line and one added line. This is the same approach used by Git and most professional diff tools.

Can I compare documents with this tool?

Yes. Copy the text from both documents and paste them into the two boxes. The tool highlights every line that differs. For best results, ensure both texts have consistent line breaks before comparing.

What algorithm is used to compare text in a diff tool?

Most diff tools use the Longest Common Subsequence (LCS) algorithm, which finds the largest set of lines that appear in the same order in both versions. Lines not in the LCS are marked as added or removed. The Unix diff utility pioneered this approach in 1974. More advanced tools use the Myers diff algorithm, which produces the minimal number of changes needed to transform one text into another.

How do I compare two versions of a file in Git?

Use git diff to compare the working directory to the last commit, git diff HEAD~1 HEAD to compare the last two commits, or git diff branch1..branch2 to compare two branches. Git diff outputs the result in unified diff format, which shows context lines around changes. GitHub and GitLab display this as a visual side-by-side diff in their pull request interface.

What is a merge conflict and how do diffs help resolve them?

A merge conflict occurs when two people edit the same lines of a file in different branches. Git cannot automatically choose which version to keep and marks the conflict with <<<<<<< and >>>>>>> markers. A diff tool helps you see exactly what each branch changed on the conflicting lines, so you can make an informed decision about which version to keep or how to combine them.

How It Works

This tool splits both inputs into arrays of lines and computes a line-by-line diff using the Longest Common Subsequence (LCS) algorithm. Lines in the LCS appear in both versions (unchanged). Lines not in the LCS are marked as removed (in red) from the left version or added (in green) in the right version. The comparison is case-sensitive and whitespace-sensitive.

Unified Diff Format

The standard unified diff format (used by Git and the Unix diff command) shows a few lines of context around each change, with - marking removed lines and + marking added lines. The @@ header shows the line numbers where the change occurs in each version. Understanding this format helps you read Git diffs, patch files, and code review comments on GitHub.

Common Use Cases

Developers use diff tools to review changes before committing, compare config files between environments, spot differences in log files, and check if two copies of a document have drifted apart. Writers use them to compare draft revisions. Legal teams use them to compare contract versions. Any situation where "what changed?" is the question, a diff tool is the answer.

When to Use This

Use to compare two versions of a document before sending to a client, to spot differences between a working and broken config file, to verify that two text outputs from different systems are identical, or to quickly identify which lines changed between two exported reports without opening a full code editor.

More Free Tools

🎂

Age Calculator

Calculate your exact age in years, months, and days plus days until your next birthday.

Checkerboard Pattern Generator

Generate a custom checkerboard or chess-grid pattern with any colors, cell size, and dimensions.

🔗

URL Encoder & Decoder

Encode special characters for safe use in URLs, or decode percent-encoded URLs.

🎬

Video Resolution Checker

Identify video resolution standard, aspect ratio, megapixels, and recommended streaming bitrate.

View all tools →