How to Compare Two Text Files in Notepad++

Often times you may need to compare two text files or documents while you are writing code or an article. In this tutorial, I will demonstrate how to easily compare two files using the Notepad++ text editor.

Notepad++ is a widely used text editor (source code editor) software that is available in multiple languages. Although it's not a WYSIWYG web design software, it can still be considered as a web design software since you can use it for any type of design, coding and development related work such as writing HTML, CSS, JavaScript, PHP, Python, ASP code and others.

How to Compare Two Text Files in Notepad++  - 1

With Notepad++, you can create any type of text-based files, edit HTML files, edit CSS files and work on other programming related tasks. You can think of it like a much improved version of the basic Notepad application on Windows or the TextEdit on Mac.

One of the highly useful editing tasks that you can do on Notepad++ (thanks to a great plugin) is to compare the contents of two files side by side, with the click of a button, as long as they are text based and can be opened by Notepad++. This is especially handy while doing revisions in your code, checking multiple versions of the same files, comparing lists, comparing the same resources you have downloaded from different sources, writing articles or updating posts on your blog.

Now, let's see how file comparison in Notepad++ works.

Compare Two Text Files in Notepad++

Notepad++ doesn't offer file comparison feature by default, hence, we will use a free plugin to do this task. The plugin is called ComparePlugin and it is available for download on this link. It is one of the best Notepad++ plugins and it is one that I use frequently while coding.

The rest of this tutorial will assume that you have downloaded and installed the ComparePlugin plugin to your Notepad++ installation folder (simply put the plugin files into the plugins folder).

TIP: You can download and install more useful Notepad++ plugins from the following page:
Notepad++ Plugins -

STEP 1: Start Notepad++ application on your computer and open the two text files that you want to compare.

Note that this comparison works on any text based files such as .txt, .html, .css, .js, .php, .xml, .xhtml, .c, .ini, .java, .py, .r, .sql and many other file formats.

STEP 2: Once the files to be compared are open, you can do the comparison in two ways. The simpler way is to use the keyboard shortcut Alt + D (Option + D on Mac).

Pressing the comparison shortcut keys will perform a super-quick comparison between the two files and display the result. The two files will be displayed side by side (perfectly suitable for live comparison), the lines that are not the same on both files will be highlighted, and the Nav Bar on the right side will show where the different lines are located on the files.

How to Compare Two Text Files in Notepad++  - 2

Alternatively, you can use the plugin options accessed from the top menu, Plugins > Compare which has a number of options to compare files, clear results, compare to last save of the same file, and more.

How to Compare Two Text Files in Notepad++  - 3

Once you identify the different lines with the help of the comparison, you can do the necessary edits on the files you are working.

TIP: You can also check the following Notepad++ tip that will help you while editing multiple files at the same time: How to Change Code in Multiple Files

f t g+ in