/ developer & network toolbox
← all tools

$ diff

runs locally

Text Diff

Compare two blocks of text line by line and highlight what was added or removed.

diff — invoker.tools

Line-based diff, computed entirely in your browser.

About the Text Diff

This text diff tool compares an original and a changed block of text, line by line, and shows exactly what was added, removed or left unchanged. Added lines appear in green with a leading plus sign, removed lines in red with a leading minus sign, and unchanged lines are dimmed but kept for context, alongside a running count of how many lines were added and removed.

Under the hood it uses a longest-common-subsequence (LCS) alignment, the same family of algorithm behind git's own diff, rather than a naive index-by-index comparison. That means inserting a single line near the top does not make every line after it look changed: the algorithm finds the longest run of lines both versions share, and only flags the lines that genuinely differ.

It is useful for comparing two versions of a config file, checking what changed between two drafts of an email or document, spotting new error lines between two log exports, or reviewing an edit without opening git or a desktop merge tool.

The comparison runs entirely in your browser: paste the original text on the left, the changed text on the right, and press compare. Nothing is uploaded to a server, there is no file picker, and it does not connect to an actual git repository, only to whatever text you paste in.

How to use it

  1. Paste the original text into the first box, labeled original.
  2. Paste the updated text into the second box, labeled changed.
  3. Click compare to run the diff.
  4. Read added lines in green with a leading + sign.
  5. Read removed lines in red with a leading - sign.
  6. Unchanged lines stay dimmed with no marker, shown for surrounding context.
  7. Edit either box and click compare again whenever you update the input; there is no auto-refresh.

Examples

  • Paste an old and a new nginx.conf to see exactly which directives were added, removed or left untouched.
  • Compare two drafts of an email to check what wording changed between versions.
  • Diff yesterday's and today's log export to find newly appeared error lines.
  • Paste two exports of a JSON config, formatted first with a JSON formatter, to make key-by-key changes easy to spot.
  • Compare two CSV exports line by line to catch new or missing rows between snapshots.
  • Paste a previous and current robots.txt to confirm only the intended lines changed before deploying.

How the diff algorithm works

The tool splits both texts into lines and builds a dynamic-programming table over every pair of lines from each side, computing the longest common subsequence: the longest ordered set of lines both versions share. It then walks that table to reconstruct the alignment, marking a line as unchanged where it matches, and as added or removed where it does not.

This is the same underlying idea as git diff and most desktop diff tools, which is why it correctly lines up matching content even when several lines were inserted or deleted in the middle of a file, instead of flagging everything after the change as different.

The trade-off is cost: building the table takes time and memory roughly proportional to the number of lines in one text multiplied by the number of lines in the other. There is no hard line limit enforced by the tool, but pasting two very large files (tens of thousands of lines each) can make the comparison slow or memory-heavy, since it all runs in the browser tab rather than on a server.

Line diff versus character diff

  • Line diff (this tool): compares whole lines, marking each one added, removed or unchanged. Fast to scan, and the standard way to read diffs for config files, code and logs.
  • Character or word diff (not offered here): highlights the exact word or character that changed inside a line, which suits prose editing but is a different kind of tool.
  • Consequence: if only a single comma changes anywhere inside a long line, this tool marks that entire line as removed and its replacement as added, since the comparison unit is the whole line, not individual characters.
  • Whitespace and line endings count: a trailing space, a tab versus spaces, or CRLF versus LF line endings make two otherwise identical-looking lines register as different, because comparison is an exact string match per line.

What this tool is not

It is worth being precise about scope, since searches for a diff tool often expect git or merge functionality specifically.

  • Not connected to a real git repository: it does not read your working tree, does not run git diff for you, and does not understand commits, branches or patches.
  • Not a file-upload tool: there is no file picker, only two paste boxes. Copy the contents of each file in manually.
  • Not a merge tool: it highlights differences but has no conflict-resolution UI for combining both sides into one result.
  • Not a side-by-side viewer: output is a single unified list, top to bottom, with +/- markers rather than two columns.

Frequently asked questions

Is this the same as running git diff?

Not literally: there is no git integration, so it never touches a repository or commit history. Conceptually it is close, since both use a longest-common-subsequence style alignment, but here you simply paste two blocks of text.

Can I diff two files directly?

There is no file upload. Open each file, copy its contents, and paste them into the original and changed boxes.

Does it merge the two versions for me?

No. It is a diff viewer that highlights what changed; it has no merge or conflict-resolution feature for combining both sides into a single result.

Why is an entire line marked as changed when only one word is different?

The comparison works line by line, not character by character. If any part of a line differs, the whole line is shown as removed on one side and added on the other.

Does it detect trailing whitespace or CRLF vs LF differences?

Yes. Lines are compared with an exact string match, so a trailing space, tabs versus spaces, or different line-ending characters will make two visually identical lines register as changed.

Is there a size limit on how much text I can compare?

No hard limit is enforced, but the underlying algorithm scales with the number of lines on each side multiplied together, so very large inputs, tens of thousands of lines per side, can become slow in the browser. For huge files, a desktop diff tool will generally be faster.

Is my text uploaded anywhere?

No. The diff is computed entirely client-side in your browser; neither the original nor the changed text is sent to a server.

What do the added and removed counts mean?

They are the total number of lines flagged as added (green, +) and removed (red, -) across the whole comparison, shown above the line-by-line output.

Can I diff JSON or YAML files with this?

Yes, paste them as-is. Formatting both sides first with a JSON or YAML formatter tends to make the diff cleaner, since consistent indentation avoids lines being flagged as changed purely due to whitespace.

Does it show a side-by-side comparison?

No, output is a single unified list read top to bottom, with + and - markers, rather than two columns placed next to each other.

More text tools