Skip to content

Text Diff

Paste two versions of a text, config or code file to see exactly which lines were added, removed or changed. Changed words are highlighted inside each line.

Original
Changed

Last reviewed:

What is a text diff?

A diff shows the smallest set of changes that turns one text into another: lines removed from the original, lines added in the changed version, and everything in between that stayed the same. It is the format behind git diff, code review tools and patch files. Rather than presenting two blocks of text for you to compare by eye, a diff points straight at what changed, which is essential when a config file has hundreds of lines and only one value is different.

Most diff tools, including this one, work line by line. They look for the longest common subsequence: the largest set of lines that appear in both texts in the same order. Lines outside that sequence are reported as removed or added. This tool calculates the sequence exactly using dynamic programming, after first skipping identical lines at the start and end. When a removed line and an added line sit opposite each other, it then diffs them word by word, so a changed port number or hostname is highlighted inside the line.

There is often more than one valid minimal diff, especially when lines repeat, such as closing braces or blank lines. Different tools pick different alignments. Git, for example, uses the Myers algorithm by default and can also use "patience" or "histogram" diffs. The changes reported are equivalent but may be grouped slightly differently from what you see here.

How to use this tool

  1. Paste the old version into Original and the new version into Changed, or use the Paste button above each box. The comparison updates as you type. Sample loads two versions of a YAML config.
  2. Choose Side by side to see both versions in columns with line numbers, or Unified to see one column where removed lines (−) are followed by added lines (+), like git diff.
  3. Read the counts next to the options: green for lines added and red for lines removed. Inside changed lines, the exact words that differ are highlighted.
  4. Tick Ignore whitespace to ignore leading and trailing spaces and treat runs of spaces and tabs as one space. Tick Ignore case to treat upper and lower case as equal.
  5. Tick Only show changes to hide long unchanged stretches, keeping three lines of context around each change.
  6. Swap exchanges the two texts and Clear empties both.

Examples

A Dockerfile update

Original:

FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["node", "server.js"]

Changed:

FROM node:22-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
USER node
EXPOSE 3000
CMD ["node", "server.js"]

The unified view shows three lines added and two removed:

- FROM node:20-alpine
+ FROM node:22-alpine
  WORKDIR /app
  COPY package*.json ./
- RUN npm install
+ RUN npm ci --omit=dev
  COPY . .
+ USER node
  EXPOSE 3000
  CMD ["node", "server.js"]

In the first pair, only 20 and 22 are highlighted inside the lines.

Word-level highlighting

From the sample, the database line changes from url: postgres://localhost:5432/app to url: postgres://db.internal:5432/app. The words that differ are marked inside the line:

url: postgres://[-localhost-]{+db.internal+}:5432/app

Here [-…-] marks the removed text and {+…+} the added text. The tool shows them in red and green.

Ignoring whitespace

Comparing const total = a + b; / return total; with const total = a + b; / return total; reports two lines removed and two added. With Ignore whitespace ticked, the tool reports no differences, because only spacing changed.

Common errors and how to fix them

  • Every line shows as changed. Usually different line endings or indentation. Windows \r\n endings are handled automatically, but tabs versus spaces or re-indentation are not; tick Ignore whitespace.
  • One extra empty line at the end. One text ends with a newline and the other does not, so the last line differs by an empty line. It is safe to ignore, though some tools, such as Git, report it as "No newline at end of file".
  • A small change shows as a large block. Reformatted content, such as JSON minified on one side and pretty-printed on the other, cannot line up. Format both texts the same way first.
  • Lines that moved show as removed and added. A line diff has no concept of "moved". Sort both inputs first if order does not matter, such as lists of dependencies.
  • "These texts are too large to compare in the browser." The region between the identical start and end is too big for the exact algorithm (more than 25 million line pairs, for example 5,000 different lines on each side). Compare smaller sections, or use git diff --no-index locally.
  • Differences you cannot see. Non-breaking spaces, zero-width characters and lookalike letters render identically. If the word highlight marks text that looks equal, retype it.

When developers use this

  • Comparing a configuration file on a server with the version in the repository to find drift.
  • Checking what changed between two API responses, log excerpts or generated files.
  • Reviewing a colleague's edited paragraph or SQL query when no version control is involved.
  • Confirming that a refactor or formatter changed only whitespace, using Ignore whitespace.
  • Comparing environment variable lists between staging and production before a release.
  • Finding why two files with "the same" content produce different checksums.

Privacy and how it works

The comparison runs entirely in your browser. Both texts stay in the tab, and nothing is uploaded or stored. That matters because diffs are often run on exactly the files you should not paste into online services: production configs, .env files, database dumps and customer data.

Limitations

  • The comparison is line-based; it does not understand JSON, YAML or code structure. Two JSON files with the same data in a different key order show as different.
  • Very large inputs with many differences can be slow or exceed the size limit, because the exact algorithm needs memory for every pair of differing lines.
  • There is no export to a patch file. For patches, use diff -u or git diff.

FAQ

How does the tool decide which lines changed?

It finds the longest sequence of lines that appear in both texts in the same order and marks the remaining lines as removed or added. Removed and added lines next to each other are paired and compared word by word.

What is the difference between side by side and unified views?

Side by side puts the two versions in parallel columns, which is easier for reading changed lines. Unified shows a single column with removed lines followed by added ones, the format used by git diff and patch files, and fits narrow screens better.

Does Ignore whitespace change the displayed text?

No. It only affects how lines are compared. The lines are shown exactly as you pasted them, including their original spacing.

Can I compare JSON objects regardless of key order?

Not directly; a line diff sees reordered keys as changes. Run both documents through the JSON formatter with Sort keys enabled, then compare the results.

Why does my diff differ from Git's?

When lines repeat, several minimal diffs are equally valid, and Git's Myers algorithm may choose a different alignment. Both show the same content changes, just grouped differently.

Can I compare binary files or images?

No. The tool compares text line by line. For binary files, compare their hashes to see whether they are identical.

Is there a size limit?

Identical lines at the start and end are skipped cheaply, so long files with a few changes work well. The limit applies to the differing middle part: about 25 million line pairs.

Guides