Skip to content

Text Diff - Compare Two Texts Side by Side

Original text
Modified text

About the Text Diff Tool

Comparing two versions of a document, config file, or code snippet by eye is unreliable, especially once the text grows past a few dozen lines. This tool takes two blocks of text and highlights every difference using colour-coded output: lines present only in the second text are shown in green (added), lines present only in the first text are shown in red (removed), and unchanged lines are displayed without highlighting. A stats bar at the top summarises the total number of additions, removals, and unchanged lines so you can gauge the scope of changes at a glance.

How the Diff Algorithm Works

The comparison is performed using a longest common subsequence (LCS) algorithm. LCS identifies the longest sequence of lines that appear in both texts in the same order. Any line not part of this shared subsequence is classified as either added or removed. This line-based approach is the same foundation used by version control systems like Git and by the classic Unix diff utility. It gives accurate, predictable results for plain text of any kind.

Features

  • Line-based comparison. Each line is treated as one unit. Added, removed, and unchanged lines are clearly separated in the output.
  • Colour-coded output. Green highlights mark lines that were added. Red highlights mark lines that were removed. Unchanged lines appear in their default style.
  • Stats bar. A summary at the top shows how many lines were added, removed, and unchanged, giving you a quick overview of the differences.
  • Client-side only. The entire diff runs in your browser. No data is sent to any server, and nothing is stored after you close the tab.

Common Use Cases

Developers compare two versions of a configuration file or code snippet to spot unintended changes. Technical writers diff two drafts of a document to review edits. QA engineers compare API responses from staging and production environments. System administrators check differences between server configs across environments. Anyone who needs to answer the question "what changed between these two texts" can paste both versions into this tool and get a clear, visual answer in seconds.

Related Tools

Frequently Asked Questions

What diff algorithm does this tool use?
The tool uses a longest common subsequence (LCS) algorithm to compute line-based differences between the two texts. LCS finds the longest sequence of lines that appear in both texts in the same order, then marks everything else as either added or removed. This is the same foundational approach used by tools like git diff and the Unix diff command.
Can it handle large texts?
Yes. The diff runs entirely in your browser, so there is no upload limit or server timeout. Performance depends on your device, but modern browsers handle documents with thousands of lines comfortably. For very large files, the initial comparison may take a moment, but the results are displayed as soon as the calculation finishes.
Is my text sent to a server?
No. All processing happens client-side in your browser using JavaScript. Your text is never transmitted over the network, stored on disk, or logged anywhere. You can verify this by checking the network tab in your browser's developer tools while using the tool.
How is this different from the JSON Diff tool?
The JSON Diff tool parses both inputs as JSON and compares their structure, highlighting differences in keys, values, and nesting. This Text Diff tool treats both inputs as plain text and compares them line by line, regardless of format. Use JSON Diff when you want a structural comparison of JSON data, and Text Diff when you want to compare any two blocks of text.