Diff
checker
Text
Text
Images
Documents
Excel
Folders
Legal
Enterprise
Desktop
Pricing
Sign in
Download Diffchecker Desktop
Compare text
Find the difference between two text files
Tools
History
Real-time editor
Hide unchanged lines
Disable line wrap
Layout
Split
Unified
Diff precision
Smart
Word
Char
Syntax highlighting
Choose syntax
Ignore
Transform text
Go to first change
Edit input
Diffchecker Desktop
The most secure way to run Diffchecker. Get the Diffchecker Desktop app: your diffs never leave your computer!
Get Desktop
Untitled diff
Created
11 years ago
Diff never expires
Clear
Export
Share
Explain
1 removal
Lines
Total
Removed
Characters
Total
Removed
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
39 lines
Copy
53 additions
Lines
Total
Added
Characters
Total
Added
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
90 lines
Copy
Copy
Copied
Copy
Copied
function blink() {
document.getElementById('caret').hidden ^= 1;
blinkTimeout = setTimeout(blink, 500);
}
var mydiv = document.getElementById('mydiv'),
var mydiv = document.getElementById('mydiv'),
Copy
Copied
Copy
Copied
myta = document.getElementById('myta')
;
myta = document.getElementById('myta')
,
blinkTimeout = setTimeout(blink, 500),
lastSelectionStart = 0,
lastSelectionEnd = 0,
whichSelection = true;
function updateDiv() {
function updateDiv() {
var fc;
var fc;
while (fc = mydiv.firstChild) mydiv.removeChild(fc);
while (fc = mydiv.firstChild) mydiv.removeChild(fc);
Copy
Copied
Copy
Copied
if (myta.selectionStart != lastSelectionStart) {
lastSelectionStart = myta.selectionStart;
whichSelection = false;
}
if (myta.selectionEnd != lastSelectionEnd) {
lastSelectionEnd = myta.selectionEnd;
whichSelection = true;
}
var cursorPos = whichSelection ? myta.selectionEnd : myta.selectionStart;
for (var i = 0; i < myta.value.length; i++) {
for (var i = 0; i < myta.value.length; i++) {
Copy
Copied
Copy
Copied
if (i == cursorPos) {
var caret = document.createElement('span');
caret.id = 'caret';
caret.appendChild(document.createTextNode('\xA0'));
mydiv.appendChild(caret);
clearTimeout(blinkTimeout);
blinkTimeout = setTimeout(blink, 500);
}
var span = document.createElement('span');
var span = document.createElement('span');
span.className = Math.random() < 0.5 ? 'green' : 'red';
span.className = Math.random() < 0.5 ? 'green' : 'red';
span.appendChild(document.createTextNode(myta.value[i]));
span.appendChild(document.createTextNode(myta.value[i]));
mydiv.appendChild(span);
mydiv.appendChild(span);
}
}
Copy
Copied
Copy
Copied
if (myta.value.length == cursorPos) {
var caret = document.createElement('span');
caret.id = 'caret';
caret.appendChild(document.createTextNode('\xA0'));
mydiv.appendChild(caret);
clearTimeout(blinkTimeout);
blinkTimeout = setTimeout(blink, 500);
}
};
};
myta.addEventListener('input', updateDiv);
myta.addEventListener('input', updateDiv);
Copy
Copied
Copy
Copied
myta.addEventListener('focus', updateDiv);
myta.addEventListener('mousedown', function() {
setTimeout(updateDiv, 0);
});
myta.addEventListener('keydown', function() {
setTimeout(updateDiv, 0);
});
myta.addEventListener('blur', function() {
document.getElementById('caret').hidden = true;
clearTimeout(blinkTimeout);
});
body { position: relative }
body { position: relative }
div, textarea {
div, textarea {
-webkit-text-size-adjust: none;
-webkit-text-size-adjust: none;
width: 100%;
width: 100%;
white-space: pre-wrap;
white-space: pre-wrap;
word-wrap: break-word;
word-wrap: break-word;
overflow-wrap: break-word;
overflow-wrap: break-word;
font: 1rem sans-serif;
font: 1rem sans-serif;
padding: 2px;
padding: 2px;
margin: 0;
margin: 0;
border-radius: 0;
border-radius: 0;
border: 1px solid #000;
border: 1px solid #000;
resize: none;
resize: none;
}
}
textarea {
textarea {
position: absolute;
position: absolute;
top: 0;
top: 0;
color: transparent;
color: transparent;
background: transparent;
background: transparent;
}
}
.red { color: #f00 }
.red { color: #f00 }
.green { color: #0f0 }
.green { color: #0f0 }
Copy
Copied
Copy
Copied
#caret {
display: inline-block;
position: absolute;
width: 1px;
background: #000;
}
#caret[hidden] { display: none }
Copy
Copied
Copy
Copied
<div id="mydiv"
></div>
<div id="mydiv"
><span id="caret"> </span
></div>
<textarea id="myta" autofocus=""></textarea>
<textarea id="myta" autofocus=""></textarea>
Saved diffs
Original text
Open file
var mydiv = document.getElementById('mydiv'), myta = document.getElementById('myta'); function updateDiv() { var fc; while (fc = mydiv.firstChild) mydiv.removeChild(fc); for (var i = 0; i < myta.value.length; i++) { var span = document.createElement('span'); span.className = Math.random() < 0.5 ? 'green' : 'red'; span.appendChild(document.createTextNode(myta.value[i])); mydiv.appendChild(span); } }; myta.addEventListener('input', updateDiv); body { position: relative } div, textarea { -webkit-text-size-adjust: none; width: 100%; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: break-word; font: 1rem sans-serif; padding: 2px; margin: 0; border-radius: 0; border: 1px solid #000; resize: none; } textarea { position: absolute; top: 0; color: transparent; background: transparent; } .red { color: #f00 } .green { color: #0f0 } <div id="mydiv"></div> <textarea id="myta" autofocus=""></textarea>
Changed text
Open file
function blink() { document.getElementById('caret').hidden ^= 1; blinkTimeout = setTimeout(blink, 500); } var mydiv = document.getElementById('mydiv'), myta = document.getElementById('myta'), blinkTimeout = setTimeout(blink, 500), lastSelectionStart = 0, lastSelectionEnd = 0, whichSelection = true; function updateDiv() { var fc; while (fc = mydiv.firstChild) mydiv.removeChild(fc); if (myta.selectionStart != lastSelectionStart) { lastSelectionStart = myta.selectionStart; whichSelection = false; } if (myta.selectionEnd != lastSelectionEnd) { lastSelectionEnd = myta.selectionEnd; whichSelection = true; } var cursorPos = whichSelection ? myta.selectionEnd : myta.selectionStart; for (var i = 0; i < myta.value.length; i++) { if (i == cursorPos) { var caret = document.createElement('span'); caret.id = 'caret'; caret.appendChild(document.createTextNode('\xA0')); mydiv.appendChild(caret); clearTimeout(blinkTimeout); blinkTimeout = setTimeout(blink, 500); } var span = document.createElement('span'); span.className = Math.random() < 0.5 ? 'green' : 'red'; span.appendChild(document.createTextNode(myta.value[i])); mydiv.appendChild(span); } if (myta.value.length == cursorPos) { var caret = document.createElement('span'); caret.id = 'caret'; caret.appendChild(document.createTextNode('\xA0')); mydiv.appendChild(caret); clearTimeout(blinkTimeout); blinkTimeout = setTimeout(blink, 500); } }; myta.addEventListener('input', updateDiv); myta.addEventListener('focus', updateDiv); myta.addEventListener('mousedown', function() { setTimeout(updateDiv, 0); }); myta.addEventListener('keydown', function() { setTimeout(updateDiv, 0); }); myta.addEventListener('blur', function() { document.getElementById('caret').hidden = true; clearTimeout(blinkTimeout); }); body { position: relative } div, textarea { -webkit-text-size-adjust: none; width: 100%; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: break-word; font: 1rem sans-serif; padding: 2px; margin: 0; border-radius: 0; border: 1px solid #000; resize: none; } textarea { position: absolute; top: 0; color: transparent; background: transparent; } .red { color: #f00 } .green { color: #0f0 } #caret { display: inline-block; position: absolute; width: 1px; background: #000; } #caret[hidden] { display: none } <div id="mydiv"><span id="caret"> </span></div> <textarea id="myta" autofocus=""></textarea>
Find difference