Developer Tools
Code diff checker.
Paste two versions of any text or code. We render added, removed, and unchanged lines with a simple line-by-line walk so you can review refactors at a glance.
Inputs
Diff result
Paste both versions and press Compare.
How to compare two pieces of code
Paste the earlier version into Original and the later one into Modified, then press Compare. The result starts with three counts (added, removed and unchanged lines) and then prints every line. A line that is the same in both versions starts with two spaces, a line from the original that was removed or replaced starts with -, and a line from the modified version starts with +. The lines are not colour-coded, so the prefix is what tells you which kind each line is. The text can be any language, or plain text, because the tool compares lines and does not parse code.
How the comparison works, exactly
This checker compares line 1 with line 1, line 2 with line 2, and so on. If the two lines are identical, the line counts as unchanged. If they differ, the original line is shown as removed and the modified line as added. If one side runs out of lines first, the rest of the longer side is shown as added or removed. It is a deliberate “simple line-by-line walk”. It does not search for lines that moved, so it is not the same algorithm as diff or git diff, which find the shortest set of insertions and deletions using the longest common subsequence approach described by Myers in 1986.
Worked example 1: one edited line
function total(items) {
let sum = 0;
for (const i of items) {
sum += i.price;
}
return sum;
}
Change the fourth line to sum += i.price * i.qty; and compare. The tool reports 1 added, 1 removed and 6 unchanged lines, and shows the fourth line as one - line followed by one + line. This is the case the tool is built for: an edit that keeps every other line in place.
Worked example 2: why one inserted line changes everything
Put "use strict"; on a new first line of the same function and compare. Every original line now sits one position lower in the modified text, so no line matches the line at its index. The tool reports 8 added, 7 removed and 0 unchanged lines, although a real diff would report one added line and seven unchanged. If your change inserts or deletes lines near the top, use the Text Diff Checker, which uses the Myers algorithm and shows only the real difference, or use git diff.
Worked example 3: invisible differences
- A trailing newline. Comparing
a\nb\nwitha\nbreports 1 removed line and 2 unchanged, because the first text ends with an empty final line. - Windows line endings. A file saved with CRLF endings carries a hidden carriage return on every line. Comparing
a\r\nbwitha\nbreports the first line as changed (1 added, 1 removed, 1 unchanged), even though the two look the same. Normalise line endings before you compare. - Tabs versus spaces and trailing spaces. Comparison is exact, case-sensitive and white-space-sensitive, so an indentation change shows every indented line as changed.
Getting a cleaner result
Run both versions through the same formatter first, so layout differences disappear and only real edits remain. For JavaScript use the JS formatter, for JSON the JSON formatter (or compare structure with the JSON diff), and for CSS the CSS formatter. Formatting a minified file also lets a line-based comparison work at all, since a minified file is a single line that either matches completely or not at all.
When to use something else
Use git diff inside a repository. It also works on two files outside one: git diff --no-index old.txt new.txt. Its default is the Myers algorithm, and options such as -w ignore white space changes. The POSIX diff utility prints the same kind of result with -u for the unified format. An editor’s built-in compare view is better for large files because it can show changes side by side.
Privacy
The comparison runs in your browser. The text you paste is not uploaded, stored or logged, which makes this suitable for configuration with internal names, but do not paste secrets such as passwords or API keys into any web page.
Frequently asked questions
How do I compare two pieces of code online?
Paste the original into the first box and the changed version into the second, then press Compare. The tool lists each line as unchanged, removed (-) or added (+) and totals each kind at the top.
Why does inserting one line mark so many lines as changed?
Because this tool compares line N of one version with line N of the other. An inserted line shifts everything after it by one, so none of the later lines line up. For insertions and deletions, use the Text Diff Checker or git diff, which find the matching lines.
Is this the same as git diff?
No. git diff uses the Myers algorithm by default to find a minimal set of added and removed lines. This page is a simple same-position comparison, which is faster to read for small edits but less accurate when lines move.
Can it compare JavaScript, Python or any other language?
Yes, but only as lines of text. It does not parse the language, so it will not understand moved functions or ignore comments. It works for any language, configuration file or plain text.
Why do two identical-looking files show as different?
Usually invisible characters: Windows (CRLF) versus Unix (LF) line endings, trailing spaces, tabs versus spaces, or a final newline. The comparison is exact, so any of these marks the line as changed.
Does the comparison ignore case or whitespace?
No. It is case-sensitive and white-space-sensitive. To ignore whitespace, format both texts the same way first, or use git diff with -w.
Is my code stored or sent anywhere?
No. The comparison runs entirely in your browser and the text is not uploaded. Avoid pasting credentials into any website.
Sources
Each source below was opened and checked in October 2026 (retrieved 2026-10).
- E. W. Myers, An O(ND) Difference Algorithm and Its Variations (1986): the algorithm behind diff and git diff
- Git documentation, git-diff: --no-index, the default myers algorithm, and whitespace options
- The Open Group, diff utility (POSIX): standard diff behaviour and the unified output format