Use JavaScript to Compare Differences Between Strings


Left Right


A tool to allow differences in strings of text to be compared. For each string similarities and differences should be identified and output. This application loops though each line in the text boxes and compares the contents. The output then displays any differences.

Further Uses and Ideas:

  • Track lines moved

Relevant Links

Javascript Diff Algorithm

jsdifflib - A Javascript visual diff tool & library

Version History

Version Date Description
Version 1.0 07/02/2009 Using Javascript Diff Algorithm
Version 2.0 13/01/2016 Implemented jsdifflib

Comments For This Page

jsdifflib is the latest version I am aware of.
By Daft Logic on 28th January 2016
Where is the current version of jsdifflib? On I just found the old source.
By tcnguyen on 28th January 2016
We have implemented a new algorithm that should cope better with the same words being mixed up on the same line
By Daft Logic on 13th January 2016
Hi, yes, I see this bug as well. We will work on an update...
By Daft Logic on 9th January 2016
Awesome demo! I may have found a bug, unless this is intentional, but if you re-organize the words in a line without adding/removing any extra words, no differences are tracked. For example:Input:
On 8th January 2016
If you compare for example
By Vladislav on 10th September 2015
Can you extend this program to track lines moved ?
By Hacker on 25th June 2012
blindspoon, the link [Javascript Diff Algorithm] is to an extrenal site. You will need to check their terms.
By Daft Logic on 15th February 2012
Am I allowed to copy this algorithm and use it in my own programm?Best regards, blindspoon
By blindspoon on 15th February 2012
Example data? I try my, not work, all in delete tak. I must examine sourcecode.
By peter on 5th June 2011

Add your own comment below and let others know what you think: