To compare two texts, paste the original into Left / Old Code and the new version into Right / New Code, or upload two files, then select Compare Code. The tool matches lines that are the same on both sides and marks the rest: red for removed, green for added and purple for lines that were edited.
How to compare two texts with the diff checker
- Add both versions. Paste the old text on the left and the new text on the right, or use Select Left File and Select Right File. It reads .txt, .js, .py, .html, .css, .json, .xml, .yml, .sql, .md and other plain-text files.
- Set the rules. Tick Ignore whitespace differences or Ignore case if those changes don't matter. Set Context to Only changed ±4 to hide long unchanged stretches.
- Run the diff. Select Compare Code or press Ctrl+Enter in either editor. The Side-by-Side Diff and the Detailed Diff Report fill in, and the counters show added, removed, changed and unchanged lines.
- Export it. Select Copy Diff Report or Download Report to save
code-diff-report.txtwith every change and its line numbers.
How the diff checker matches lines
The tool splits both inputs into lines and finds the longest common subsequence: the largest set of lines that appear on both sides in the same order. Those lines are unchanged. Every other line on the left was removed, and every other line on the right was added. When a removed line sits directly next to an added one, the pair is shown as a single changed line, with the part that differs highlighted inside it.
For example, compare this config:
Left Right
host = localhost host = localhost
port = 8080 port = 9090
debug = true debug = true
timeout = 30| Line | Result | Color |
|---|---|---|
| 1 and 3 | Unchanged | None |
| 2 | Changed: 8080 became 9090 | Purple |
| 4 (right only) | Added | Green |
Line numbers on each side refer to that side's own file, so you can jump to the exact spot in your editor.
Code diff checker options
- Ignore whitespace differences collapses runs of spaces and tabs and trims each line before comparing, so
port = 8080matchesport = 8080. Text that differs only by a missing space, such asa=bvsa = b, still counts as changed. - Ignore case treats
SELECTandselectas the same line, handy for SQL and HTML. - Context shows every line by default. The ±2, ±4 and ±8 settings keep only changed lines and their neighbors, and replace the rest with a "hidden line(s)" marker.
- Find in diff filters the view to rows whose text or line number contains what you type.
- Syntax Highlight guesses the language from the content, or you can force JavaScript/TypeScript, HTML/XML, CSS/SCSS, JSON or plain text.
Sync left and right scroll is on by default, so both panes move together. Turn on word wrap for long lines such as minified CSS or log entries.
Comparing XML, JSON and other structured text
A line diff is only as good as the line breaks. Two XML files that each sit on one line show up as one changed line, even if a single attribute differs. Run both through the XML formatter first so every tag has its own line, then compare. That turns this page into a usable XML diff checker.
For JSON, a text diff also flags key order and indentation. If you only care about the values, the JSON compare tool matches keys and reports changes by path, such as users[0].role.
Online diff checker vs diff and git diff
On a machine with a terminal, diff -u old.txt new.txt prints a unified diff, with removed lines starting with - and added lines with +. git diff --no-index old.txt new.txt does the same for any two files, even outside a repository. Both are good for scripts and patches.
This page is quicker when you need to compare text that came from an email, a ticket or a web form, when you want a side-by-side view, or when you're on a phone. It runs in your browser, so pasted code and configs are not uploaded. The comparison table grows with the line count of both sides, so it works best on files up to a few thousand lines each; very large files can make the tab slow.
Frequently asked questions
How do I compare two texts for differences?
Paste one text into the left box and the other into the right box, then select Compare Code. Removed lines are red, added lines green and edited lines purple.
Can I ignore spaces and indentation when comparing?
Yes. Tick Ignore whitespace differences. Extra spaces, tabs and trailing whitespace are then ignored when lines are matched.
Does it compare by word or by line?
By line. Lines are matched first, and when a line was edited, the differing part inside that line is highlighted.
Can I compare two files instead of pasting text?
Yes. Use Select Left File and Select Right File, or drag a file onto each upload box. Any plain-text file works, including code, CSV, logs and Markdown.
Is this text compare tool private?
Yes. Both texts are compared in your browser with JavaScript and never sent to a server.
What keyboard shortcuts does it support?
With the cursor in either editor, Ctrl+Enter (Cmd+Enter on a Mac) runs the comparison. Clearing and downloading use the Clear All and Download Report buttons, so your browser keeps its own Ctrl+L and Ctrl+S shortcuts.