How to Compare Two Texts and Find Differences
Whether you're reviewing code changes, checking document revisions, or spotting edits in a contract — a diff tool shows you exactly what changed, line by line.
Comparing two versions of a text manually is tedious and error-prone. Miss one changed word in a contract clause and you've missed a meaningful edit. A diff tool automates that process — it finds every addition, deletion, and unchanged line in seconds, and shows them side by side in a format that's easy to scan.
What a diff tool actually does
A diff tool takes two inputs — an original text and a changed version — and computes the minimal set of changes that transforms one into the other. The result is displayed as a set of operations: lines that were added (insertions), lines that were removed (deletions), and lines that stayed the same.
The underlying algorithm used by most professional diff tools — including Git — is called the Longest Common Subsequence (LCS). It finds the longest sequence of lines that appears in both texts in the same order, then marks everything else as either an insertion or a deletion.
Split view vs unified view
Most diff tools offer two display modes:
Split view shows the original text on the left and the changed version on the right. Deleted lines appear in red on the left, added lines appear in green on the right, and unchanged lines appear side by side. This is the easiest view to read when you want to understand the full context of a change.
Unified view shows a single column with all lines from both texts interleaved. Deleted lines are prefixed with a minus sign (−) in red, added lines with a plus sign (+) in green. This is the format you see in Git's terminal output and pull request diffs on GitHub.
For most people reviewing document changes, split view is clearer. For developers reviewing code diffs, unified view is often the standard.
When to use a diff tool
Code review. Before committing a file or submitting a pull request, running a diff against the previous version lets you catch unintended changes — whitespace you accidentally deleted, a comment you removed, or a variable name you changed in one place but not another.
Document revisions. Legal documents, contracts, and policies go through multiple drafts. A diff tool shows exactly what changed between version 2 and version 3 of a clause without requiring you to read both documents in full.
Configuration files. When something breaks after a config change, comparing the working config against the broken one immediately surfaces the difference. This is far faster than reading both files looking for a discrepancy.
Data cleanup. If you've processed a CSV or JSON file and want to verify the output, comparing the before and after versions in a diff tool shows whether any unexpected changes were made alongside the intended ones.
Content editing. Writers and editors can use a diff tool to compare two drafts of an article — useful when working with a collaborator who sends back a revised version without tracked changes.
What file types can you diff?
Any plain-text file can be compared: source code in any language (.js, .php, .py, .ts, .go, .rb, .swift, .kt), markup and config files (.html, .css, .json, .yaml, .xml, .env, .sh, .sql), and plain text documents (.txt, .md).
Binary files — images, PDFs, Word documents, spreadsheets — cannot be meaningfully compared with a text diff tool. For those, you need format-specific tools.
Comparing texts privately
Most diff tools online upload your text to a server to process it. That's a concern when the text contains sensitive content — source code you haven't published, internal policy documents, client data, or contract terms.
BG Bueno's Diff Checker runs entirely in your browser using JavaScript. Neither the original text nor the changed version is sent to any server. The LCS algorithm runs locally, the result is displayed locally, and nothing leaves your device. You can verify this by turning off your internet connection after the page loads — the tool continues to work.
Practical tips
Normalise whitespace before comparing. If one version uses tabs and the other uses spaces, or one has trailing spaces and the other doesn't, a diff tool will flag every line as changed even though the visible content is identical. Normalise both texts first for a cleaner result.
Compare small sections for long documents. Running a diff on a 5,000-line file is perfectly functional, but the result can be overwhelming to review. For large documents, consider splitting into logical sections and diffing each one separately.
Use the file upload option for code files. Opening a file directly avoids copy-paste errors — some editors add smart quotes or change apostrophes when you paste, which would show up as false positives in the diff.
BG Bueno tools
BG Bueno's own image tools are free to use, with no account required, and your files stay in your browser.
Keep reading