Developer

Text Diff Checker

Compare two texts and highlight the differences

Online Text Diff Checker

This tool compares two pieces of text side by side and highlights exactly what changed between them. Added lines are shown in green, removed lines in red, and unchanged lines in white. Use it to compare code versions, configuration files, documents, or any text.

How the Diff Is Computed

The comparison uses the Longest Common Subsequence (LCS) algorithm β€” the same algorithm underlying Git's diff engine. It finds the maximum number of lines that are identical between the two texts (in the same order), then marks everything else as added or removed. The result is a minimal diff that makes the least number of changes to transform the original into the new text.

Similarity Score

The similarity percentage at the top shows how alike the two texts are: 100% means identical, 0% means completely different. It is calculated as: unchanged lines Γ· total lines Γ— 100.

Typical Uses

  • Compare two versions of a code file before and after a change
  • Review what changed in a configuration file (nginx.conf, .env, docker-compose.yml)
  • Check differences between two API responses
  • Proofread two drafts of a document
  • Compare SQL query outputs

Frequently Asked Questions

What is a diff?
A diff (short for "difference") is a comparison of two pieces of text that shows what was added, removed, or unchanged between them. The name comes from the Unix `diff` command, first released in 1974. Diffs are the foundation of version control systems like Git β€” every commit is essentially a diff stored against the previous state of the code.
What algorithm does this diff checker use?
This tool uses the Longest Common Subsequence (LCS) algorithm to compute the diff. LCS finds the longest sequence of lines that appear in both texts in the same order. Removed lines are what was in the original but not in the LCS; added lines are what is in the new text but not in the LCS. This is the same foundational algorithm used by the classic Unix diff and by Git.
What is the difference between a word diff and a line diff?
A line diff compares whole lines and marks an entire line as added or removed. A word diff (also called an inline diff) goes further and highlights the specific words or characters that changed within a modified line. This tool uses line-level diffing, which is the most common and universally readable format for comparing text and code.
What is unified diff format?
Unified diff format is the standard output format of `git diff` and the Unix diff command. Lines starting with + are additions, lines starting with - are removals, and lines starting with a space are unchanged context. This format can be applied to a file as a "patch" to transform the original into the modified version.
Can I use this diff checker to compare code files?
Yes β€” paste the contents of any two text-based files (code, configuration, markdown, prose) to see what changed. The diff is computed entirely in your browser so nothing is sent to a server, making it safe to use with proprietary or sensitive code.