Diff Checker: Compare Two Texts or Code Line by Line

Paste the original and the edited version to see added (+), removed (−) and unchanged lines highlighted.

Comparing two texts line by line: how to read the diff

The tool compares two texts line by line: a line found on both sides is unchanged, a line that only exists in the original is removed (−) and a line that only exists in the modified version is added (+). On the sample JSON provided, it counts 5 additions, 4 removals and 3 unchanged lines.

The algorithm

Both texts are split at line breaks. The tool then computes the longest common subsequence of the two lists of lines, as git diff does: those lines are marked unchanged, the other lines of the original are removed and the other lines of the modified text are added. When lines are replaced, removals are shown before additions.

Worked example

In the sample JSON (7 lines against 8), the opening brace, the "status": "active" line and the closing brace are unchanged. The edited name, version, description and tools lines each appear as a removal and then an addition, and "theme": "dark" is a pure addition: +5, −4, 3 unchanged. Another case: a, b, c, d against a, B, c, d, e gives +2, −1 and 3 unchanged; with “Ignore case”, b and B become equal, leaving +1 and 4 unchanged.

Options and limits

  • “Ignore whitespace” trims spaces at both ends of a line and collapses runs of spaces into one; “Ignore case” compares in lower case.
  • Comparison works on whole lines: a single changed character flags the entire line, with no highlighting inside it.
  • An inserted block is recognised: 11 lines added at the top of a 15-line text give 11 additions and 15 unchanged lines. Limit: once the common start and end are set aside, if the differing zone exceeds about 10 million cells (original lines × modified lines, roughly 3,160 lines on each side), it is shown as one block, every line as a removal then as an addition, even the unchanged ones. A moved block shows as removed at its old position and added at the new one.

The “Swap texts” button (double arrows) swaps the original and the modified version. The comparison runs in your browser.

Frequently Asked Questions

How do I compare two versions of a code file?

Paste the original on the left and the modified version on the right: the tool shows added lines in green (+), removed lines in red (−) and the number of unchanged lines. With the sample JSON provided, it finds 5 additions, 4 removals and 3 unchanged lines.

Why does an edited line show up as both removed and added?

The tool compares whole lines, not characters. A line where a single word changes no longer equals the old one, so it is counted as a removal (the old line) followed by an addition (the new one). Changing "version": "1.0.0" to "2.0.0" therefore adds +1 and −1 to the counters.

What does the “Ignore whitespace” option do?

It trims spaces at the start and end of each line and collapses any run of spaces into one before comparing. Code that has only been re-indented then no longer shows as changed.

Does the tool detect a moved block of lines?

No: a moved block shows as removed at its old position and added at the new one. The rest of the text stays aligned whatever the size of the block, because the tool computes the longest common subsequence of the two texts, as git diff does.

Is this tool really free?

Yes, all tools on Kristools are 100% free and accessible without registration.

Is my data protected?

Yes. All processing is performed directly and securely inside your browser. No personal data is sent to our servers.