Skip to content
HexSlate

Text Diff

Original text0
Changed text0

How the comparison is made

A Myers diff (Myers, 1986), the algorithm Git uses by default, run through jsdiff. Word granularity refines it rather than replacing it: only lines already flagged as changed get a second, word-level pass.

The two panes do not line up row for row. Aligning them needs blank placeholder rows on whichever side is shorter, and these panes are editable text boxes: a placeholder is a row you could click into and type in. So each pane shows only the lines that side has.

Common problems

  • Every line is marked changed but the text looks the same. Invisible characters: a trailing space, a tab against spaces, CRLF against LF. Ignore whitespace trims each line end before comparing; a run of spaces mid-line still counts.
  • Copy as patch ignores all three ignore options. The patch is built from the two texts exactly as pasted. A patch is applied by matching its context lines against the real file character for character, so context with the indentation trimmed, the case folded or the blank lines removed would match nothing.
  • Ignore blank lines changes the line numbers. Blanks are removed before comparing, not skipped when reporting, so numbers follow the filtered text.

Frequently asked questions

What can I do with the unified patch?

Same format git diff prints, except that the paths in the header are plain file names with no a/ and b/ prefixes. Nothing to strip, so apply it with patch -p0 < patch.diff from the directory holding the file, or paste it into a pull request comment.

Is my text uploaded anywhere?

No. Both sides are compared in this tab and neither is sent anywhere or written to the address bar. That matters more than it sounds for a diff tool: the two things people most often compare are configuration files and contract drafts.

Can I compare two files instead of pasting?

Open each file and paste its contents. There is no file picker here because a diff is almost always between two things you already have open, and the paste is faster than two trips through a file dialog.

Why does one changed space mark the whole line?

Because the line genuinely changed, and a diff that hid it would be lying. Turn on ignore whitespace when you are reviewing meaning rather than formatting; turn it off when a trailing space is the bug you are hunting.

Does this use the same algorithm as git diff?

Same family. Git's default is Myers. Its --patience and --histogram alternatives, which read better on code with repeated lines, are not implemented here.