We use cookies

We use cookies and similar technologies to enhance your browsing experience, analyze site traffic, and personalize content and ads. By clicking "Accept", you consent to our use of cookies. Learn more in our Privacy Policy.

⟨±⟩

Diff Checker

by Cosmovex

+5 added~10 changed
Original
16 lines
Modified
21 lines
ORIGINAL
MODIFIED
1function greet(name) {
1function greet(name, title = "") {
2 console.log("Hello, " + name + "!");
2 const fullName = title ? `${title} ${name}` : name;
3 console.log(`Hello, ${fullName}!`);
3 return true;
4 return true;
4}
5}
5 
6 
6const PI = 3.14159;
7const PI = 3.14159265;
7const greeting = "Hello World";
8const greeting = "Hello, World!";
8 
9 
9// Old API endpoint
10// Updated API endpoint
10const API_URL = "http://api.example.com/v1";
11const API_URL = "https://api.example.com/v2";
11 
12 
12function fetchData(url) {
13async function fetchData(url) {
13 return fetch(url)
14 try {
14 .then(res => res.json())
15 const res = await fetch(url);
15 .catch(err => console.error(err));
16 return await res.json();
17 } catch (err) {
18 console.error("Fetch error:", err);
19 return null;
20 }
16}
21}
Legend:■ Added■ Removed■ Changed6 unchanged · 31 total lines shown

Free Online Diff Checker — Compare Text and Code

Compare two texts, files, or code snippets side-by-side with character-level highlighting. See exactly which lines were added, removed, or changed. Supports unified diff format, ignore whitespace, ignore case, and Ctrl+F search within the diff output.

No signup required. All comparison happens in your browser — your text is never sent to a server.

More Developer Tools

View all tools →
.*
Regex Tester
Test & debug regular expressions
Cron Builder
Build & explain cron expressions
🎨
Color Picker
Pick colors, convert formats
Unix Timestamp
Convert Unix timestamps
{ }
JSON Formatter
Format, validate & explore JSON
YAML Formatter
Lint, format & convert YAML
</>
XML Formatter
Beautify & validate XML
CSV Formatter
View & format CSV tables

A diff checker takes two blocks of text and shows you exactly what changed between them: which lines were added, which were removed, and which were modified. Paste an old version on the left and a new version on the right, and the tool aligns matching lines and highlights the differences so you can scan them at a glance instead of reading both versions word by word.

This is useful any time you have two slightly different versions of something and need to know precisely where they diverge: two drafts of an email, config files from staging and production, a function before and after a refactor, or JSON responses from two API calls. Everything runs in your browser. The text you paste is never uploaded to a server, which matters when you are comparing logs, credentials, or anything else you would rather not send over the network.

How it works

Paste your two texts into the left and right panels. The tool breaks each side into lines, finds the longest run of lines that match between them, and uses those anchors to line up the rest. Lines that exist only on the right are marked added, lines that exist only on the left are marked removed, and a removed line directly followed by an added line in the same spot is shown as a change.

Key features:

  • Line-by-line alignment so unchanged regions stay paired up and only real differences stand out.
  • Inline (word-level) highlighting inside changed lines, so a one-character edit doesn't light up the whole line.
  • Ignore options for trailing whitespace, case, and blank lines, which cut noise when the only "difference" is formatting.
  • Side-by-side and unified views — side-by-side for reading, unified (a single +/- column) for copying into a commit message or ticket.

No file uploads, no account, no size limit beyond what your browser can hold in memory.

A worked example

Say you tweaked a config and want to confirm only what you intended changed.

Left (old):

host = localhost
port = 5432
timeout = 30
retries = 3

Right (new):

host = localhost
port = 5432
timeout = 60
retries = 3
ssl = true

The checker keeps lines 1, 2, and 4 paired and unhighlighted. It marks timeout = 30timeout = 60 as a change, with only 30/60 highlighted inline. It marks ssl = true as an added line at the end. You can now say with certainty that two things changed and nothing else moved. Without a diff, line 5 being new can easily push your eye out of alignment and make you think later lines also changed when they didn't.

Common use cases

  • Code review on the fly — compare a function before and after an edit without committing or opening a full review tool.
  • Config drift — diff staging.env against prod.env, or a working config against a broken one, to find the single line that differs.
  • Catching unintended edits — paste the original and your modified version to confirm a find-and-replace didn't touch anything it shouldn't have.
  • Comparing API responses — drop two JSON payloads in to see which fields a backend change altered.
  • Document and prose editing — see what an editor or collaborator actually changed between two drafts.
  • Log triage — diff a clean run against a failing run to isolate the lines unique to the failure.
  • Resolving merge confusion — when a merge tool's output is hard to read, diffing the two sides plainly often makes the conflict obvious.

Tips and gotchas

A few things trip people up:

  • Whitespace counts by default. A trailing space or a tab-vs-spaces difference will register as a change. If lines look identical but are flagged, turn on ignore whitespace or ignore trailing whitespace.
  • Line endings can lie. Text copied from Windows may carry \r\n while your other side uses \n. Some diffs flag every line because of this. Normalizing line endings (or an ignore line endings option) fixes it.
  • Reordering looks like delete + add. If you move a block from the top to the bottom, a line-based diff shows the old location as removed and the new location as added. That's expected — line diffs don't track moves.
  • Minified or single-line content barely diffs. If your JSON or HTML is all on one line, the whole thing is one "line" and you'll get all-or-nothing highlighting. Pretty-print or format both sides first so the diff has lines to work with.

What "diff" actually means

Under the hood, a line diff solves the longest common subsequence (LCS) problem: given two sequences of lines, find the longest ordering of lines that appears in both (in the same relative order, not necessarily contiguous). Everything in that common subsequence is "unchanged"; everything left over on the left is a deletion and everything left over on the right is an insertion.

That framing explains the behavior you see. It's why a moved block reads as a delete plus an insert (the move breaks the common ordering), and why two lines that differ by one word show as a delete-then-insert pair at the line level — they're simply not the same line. Inline highlighting is a second, smaller diff run on just that changed pair, usually over words or characters, to pinpoint the actual edit. Understanding LCS also tells you why ignoring whitespace and case helps: it makes more lines compare as equal, which grows the common subsequence and shrinks the noise.

Tips

  • Format or pretty-print both sides before diffing minified JSON, HTML, or CSS so the comparison has real lines to align.
  • If identical-looking lines flag as different, enable ignore-whitespace first — trailing spaces and tab/space mismatches are the usual cause.
  • Normalize line endings when comparing text from different operating systems to avoid every line being marked changed.
  • Use the unified view when you want to paste the result into a commit message, PR description, or bug report.
  • Comparing secrets or logs is safe here since nothing leaves your browser, but still scrub anything you plan to copy elsewhere.
  • For moved blocks, diff the section in isolation rather than the whole file to see the real edit instead of a delete-plus-add pair.

How to use Diff Checker / Text Compare

  1. 1Paste the original text on the left.
  2. 2Paste the changed text on the right.
  3. 3Differences are highlighted line by line.
  4. 4Review additions and deletions — everything stays in your browser.

Frequently asked questions

What's the difference between added, removed, and changed lines?

Added lines exist only in the new (right) text, removed lines exist only in the old (left) text, and a changed line is a removed line replaced by an added one in the same position — usually shown together with the specific words that differ highlighted inline.

Why are two lines that look the same marked as different?

Almost always invisible characters: a trailing space, a tab instead of spaces, or different line endings (\r\n vs \n). Enable the ignore-whitespace or ignore-line-endings option and they should match.

Can I compare code, not just plain text?

Yes. The diff is language-agnostic and works on any text, including source code, JSON, YAML, SQL, and config files. For minified or single-line code, format both sides first so each statement is on its own line.

Is my text uploaded anywhere?

No. The comparison runs entirely in your browser using JavaScript. Nothing you paste is sent to a server, so it's safe for logs, configs, and other sensitive content.

Why does a block I moved show up as both deleted and added?

Line-based diffs match lines by position and order, not by tracking movement. Moving a block breaks the common ordering, so the old spot reads as removed and the new spot as added. This is normal.

How does it highlight changes within a single line?

After pairing a removed line with the added line that replaced it, the tool runs a second, finer diff over just those two lines at the word or character level, then highlights only the parts that actually differ.

Is there a size limit on what I can compare?

There's no hard server-side cap because it's all local, but very large inputs (tens of thousands of lines) are limited by your device's memory and CPU. For huge files, compare the relevant section rather than the whole thing.

Can I ignore case or blank lines when comparing?

Yes. Ignore-case treats uppercase and lowercase as equal, and ignore-blank-lines skips empty lines, which is handy when only formatting or capitalization differs and you want to focus on substantive changes.

← All toolsRead our guides →