Text Diff Tool Documentation

A complete guide to comparing text and files, how the file picker and diff algorithm work, and real-world uses for line-by-line text comparison.

Launch the Text Diff Tool →
On This Page
  1. What This Tool Does
  2. How the File Picker Feature Works
  3. How the Line-by-Line Comparison Algorithm Works
  4. What the Ignore Whitespace and Ignore Case Options Do
  5. Common Real-World Uses for Text Comparison
  6. Step-by-Step: Using the Tool
  7. Privacy and Data Handling
  8. Frequently Asked Questions

What This Tool Does

The Text Diff Tool compares two blocks of text — labeled Text #1 and Text #2 — line by line, and visually highlights exactly what was added, removed, or left unchanged between them. Each line in the result is color-coded and prefixed with a + or - symbol, closely mirroring the familiar visual style of diff output used throughout software version control systems.

Either text box can be filled by pasting content directly, or by clicking its label and selecting a file from your device through your browser's native file picker, which automatically loads that file's contents into the corresponding box and displays its filename underneath as a quick reference, without ever uploading the file anywhere.

How the File Picker Feature Works (and Its Real Limitations)

Clicking either "Text #1" or "Text #2" label triggers your browser's genuine, built-in file selection dialog — the exact same system file picker you'd see from any other application on your device. Once you select a file, its contents are read directly from your local disk using the browser's FileReader API and loaded into the corresponding text box automatically, with a small status indicator appearing underneath showing the filename you selected.

It's worth being clear about a genuine, unavoidable browser limitation here: for security and privacy reasons, browsers never expose a selected file's full absolute path to JavaScript, only its filename. This means the status indicator can show you selected config-old.txt, but never the full path like C:\Users\you\Documents\config-old.txt — that information is deliberately withheld by every browser from any webpage's JavaScript, regardless of how the page is built, as a basic privacy protection preventing websites from learning details about your local filesystem structure.

The file picker is also, necessarily, your operating system's standard "Open File" dialog rather than any kind of custom search interface, since JavaScript running on a webpage has no ability to browse or search a user's filesystem directly — the only filesystem access any webpage ever gets is through this exact kind of explicit, user-initiated file selection dialog, which is itself a deliberate browser security boundary.

How the Line-by-Line Comparison Algorithm Works

Determining the most useful, minimal set of differences between two blocks of text is a well-studied computer science problem, and this tool implements a standard dynamic programming approach to solve it correctly. The core idea is to build a table recording, for every possible pair of positions within the two texts, the length of the longest common subsequence of lines achievable from that point onward, working backward from the end of both texts to the beginning.

Once that table is fully built, the tool walks forward through it, at each step comparing the current line from Text #1 against the current line from Text #2: if they match, that line is marked unchanged and both positions advance together; if they don't match, the table is consulted to determine whether treating the current line from Text #1 as removed, or the current line from Text #2 as added, leads toward the longest possible common subsequence, and the appropriate choice is made and recorded. This process reliably produces the same kind of clean, minimal diff output that professional version control tools aim for, rather than a naive line-by-line comparison that would incorrectly flag every subsequent line as changed after a single early insertion or deletion threw the alignment off.

Worked Example

Comparing a three-line original text against a version with one new line inserted in the middle correctly identifies only that one new line as "added," with the lines before and after it correctly recognized as unchanged, rather than naively treating every line after the insertion point as different simply because their positions shifted.

What the Ignore Whitespace and Ignore Case Options Actually Do

The "Ignore leading/trailing whitespace" option trims whitespace from the beginning and end of each line before comparing it, which is particularly useful when comparing configuration files or code where indentation or trailing spaces might differ between two otherwise functionally identical versions, without those purely cosmetic differences being flagged as meaningful changes.

The "Ignore case" option converts each line to lowercase before comparing, useful when the specific capitalization of text doesn't matter for your purposes and you only want to see genuinely substantive differences, such as comparing two drafts of a document where someone may have inconsistently capitalized certain words without changing the actual meaning.

Both options can be toggled on or off after an initial comparison has already run, and the tool automatically re-runs the comparison immediately when either toggle changes, letting you quickly see how much of a reported difference is purely a matter of whitespace or capitalization versus a genuinely substantive change.

Step-by-Step: Using the Tool

  1. Fill in Text #1 and Text #2, either by pasting content directly or by clicking each label and selecting a file.
  2. Optionally enable Ignore Whitespace or Ignore Case if minor formatting or capitalization differences shouldn't count as meaningful changes.
  3. Click Compare. The tool runs its line-by-line comparison algorithm and displays the result.
  4. Review the color-coded output, with added lines, removed lines, and unchanged lines each clearly distinguished.
  5. Check the added/removed count summary at the top of the results for a quick numeric overview before scrolling through the full line-by-line detail.

Common Real-World Uses for Text Comparison

Comparing two versions of text content is a recurring need across many kinds of work, and a few common scenarios illustrate why having a fast, no-signup tool for it is genuinely useful:

Privacy and Data Handling

All comparison happens entirely within your browser using a local, dynamic-programming diff algorithm. No network request of any kind is made by this tool. Files selected through the file picker are read directly into browser memory from your local disk using the FileReader API and are never uploaded anywhere — neither the file content nor the filename itself is ever transmitted, logged, or stored outside your current browser session.

Frequently Asked Questions

Why does the file status indicator only show a filename and not the full file path?

This is a deliberate browser security restriction, not a limitation of this tool specifically. No webpage's JavaScript is ever given access to a selected file's full filesystem path, only its filename, as a basic privacy protection against websites learning details about your local filesystem structure.

Why did the filename indicator disappear after I started typing in that text box?

Once you manually edit a text box that was previously filled by a selected file, that content is no longer exactly what the file contained, so the filename indicator is automatically cleared to avoid implying the box still reflects the original file's unmodified contents.

Can I compare more than two files, or compare entire folders?

This tool is specifically built to compare two individual blocks of text or two individual files at a time. Comparing multiple files or entire folder structures would require a different, more specialized tool.

Does the comparison algorithm consider word-level or character-level differences within a changed line?

No, this tool performs line-level comparison: an entire line is marked as added, removed, or unchanged, but it does not further highlight which specific words or characters differ within a line that has changed.