# Compare files, folders, and text sources

IntelliJ IDEA lets you review the differences between files, folders, local files and their repository versions, database objects, and text sources.

> **Tip:**
> For more information about examining the differences between two revisions of a file or a folder, refer to [Compare file and folder versions using Diff viewer](comparing-file-versions.html).

## Compare files

Procedure: Compare two or three files

* In the   Project tool window  (`Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+1` (NetBeans), `Ctrl+Alt+L` (Visual Studio), `⌘ ⌥ L` (Visual Studio (macOS)), `Alt+1` (Eclipse), `Alt+1` (Eclipse (macOS))) , select the files you want to compare and choose `Compare Files`  , or press `Ctrl+D` (Windows), `⌘ D` (macOS), `⌘ D` (IntelliJ IDEA Classic (macOS)), `⌘ D` (macOS System Shortcuts), `Ctrl+D` (XWin), `Ctrl+D` (GNOME), `Ctrl+D` (KDE), `Ctrl+D` (Emacs), `Ctrl+D` (Sublime Text), `⌘ D` (Sublime Text (macOS)), `Ctrl+D` (NetBeans), `Ctrl+D` (Visual Studio), `⌘ D` (Visual Studio (macOS)), `Ctrl+D` (Eclipse), `⌘ D` (Eclipse (macOS))  .

* Alternatively, select one file, choose Compare With… from its context menu, and select a file that is outside your project.

> **Tip:**
> If you are comparing two files and want to add a third file to the comparison, right-click either left or right panel, select Switch to Three-Side Viewer, and load the required file by clicking Select file.

Procedure: Compare active editor with Clipboard

* Right-click anywhere in the editor and choose Compare with Clipboard from the context menu.

Procedure: Compare active editor with a project file

1. In the   Project tool window  (`Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+1` (NetBeans), `Ctrl+Alt+L` (Visual Studio), `⌘ ⌥ L` (Visual Studio (macOS)), `Alt+1` (Eclipse), `Alt+1` (Eclipse (macOS))) , right-click the file you want to compare with the currently opened file.

2. Choose Compare File with Editor from the context menu.

Procedure: Compare active editor with any file

If you often need to compare files that are outside your project with the active editor, or don't want to have the   Project tool window  (`Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+1` (NetBeans), `Ctrl+Alt+L` (Visual Studio), `⌘ ⌥ L` (Visual Studio (macOS)), `Alt+1` (Eclipse), `Alt+1` (Eclipse (macOS)))  open, you can use the Compare File with Editor action that lets you choose any file and compare it with the active editor.

To add this action to the editor tab's context menu:

1. Press `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) to open settings and then select `Appearance & Behavior | Menus and Toolbars`.

2. In the right pane, expand the Editor Tab Popup Menu node, select where you want to add the new action, click ![the Add Actions menu](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg) and select Add Action….

3. Find and add the Compare File with Editor action under `Version Control Systems | Diff & Merge`.

Procedure: Compare a local file with its repository version

1. Open the  Commit tool window (`Alt+0` (Windows), `⌘ 0` (macOS), `⌘ 0` (IntelliJ IDEA Classic (macOS)), `⌘ 0` (macOS System Shortcuts), `Alt+0` (XWin), `Alt+0` (GNOME), `Alt+0` (KDE), `Alt+0` (Emacs), `Alt+0` (Sublime Text), `⌘ 0` (Sublime Text (macOS)), `Alt+0` (NetBeans), `Alt+0` (Visual Studio), `Alt+0` (Visual Studio (macOS)), `Alt+0` (Eclipse), `⌘ 0` (Eclipse (macOS)) ) .

2. Locate the required file in a changelist and do one of the following:

* Right-click the file and select `Git | Show Diff`.

* Select the file and press `Ctrl+D` (Windows), `⌘ D` (macOS), `⌘ D` (IntelliJ IDEA Classic (macOS)), `⌘ D` (macOS System Shortcuts), `Ctrl+D` (XWin), `Ctrl+D` (GNOME), `Ctrl+D` (KDE), `Ctrl+D` (Emacs), `Ctrl+D` (Sublime Text), `⌘ D` (Sublime Text (macOS)), `Ctrl+D` (NetBeans), `Ctrl+D` (Visual Studio), `⌘ D` (Visual Studio (macOS)), `Ctrl+D` (Eclipse), `⌘ D` (Eclipse (macOS)).

* Double-click the file.

IntelliJ IDEA displays the differences in the [Diff Viewer
for Files](differences-viewer.html).

![Comparing files in IntelliJ IDEA diff viewer](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij_compareFiles.png)

| Color | Description |
| --- | --- |
|  ![New lines](https://resources.jetbrains.com.cn/help/img/idea/2026.2/diff_new_lines_color.png)  Green  | Added |
|  ![Modified lines](https://resources.jetbrains.com.cn/help/img/idea/2026.2/diff_changed_lines_color.png)  Blue  | Modified |
|  ![Deleted lines](https://resources.jetbrains.com.cn/help/img/idea/2026.2/diff_deleted_lines_color.png)  Gray  | Deleted |

To apply changes, use the chevron buttons: ![apply left](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.diff.applyNotConflictsLeft.svg) and ![apply right](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.diff.applyNotConflictsRight.svg).

To append changes, press `Ctrl` (Windows), `Ctrl` (macOS), `Ctrl` (IntelliJ IDEA Classic (macOS)), `Ctrl` (macOS System Shortcuts), `Ctrl` (XWin), `Ctrl` (GNOME), `Ctrl` (KDE), `Ctrl` (Emacs), `Ctrl` (Sublime Text), `Ctrl` (Sublime Text (macOS)), `Ctrl` (NetBeans), `Ctrl` (Visual Studio), `Ctrl` (Visual Studio (macOS)), `Ctrl` (Eclipse), `Ctrl` (Eclipse (macOS)) —  the ![apply left](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.diff.applyNotConflictsLeft.svg) ![apply right](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.diff.applyNotConflictsRight.svg) buttons will turn into ![chevron button bottom right](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.diff.arrowRightDown.svg) ![chevron button bottom left](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.diff.arrowLeftDown.svg).

### Productivity tips

Assign shortcuts for 'accept' and 'append'
: To assign shortcuts to the accept and append actions, open  the Keymap settings page `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS))  and locate these actions under Version Control Systems | Diff & Merge.

Swap sides
: When you are comparing two files, or a file with the Clipboard contents, you can swap sides by clicking ![the Swap Sides button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.actions.swapPanels.svg) on the toolbar.

Compare files from the command line
: You can compare two or three files from the command line and use IntelliJ IDEA as an external diff tool. For more information, refer to [Compare files from the command line](command-line-differences-viewer.html).

## Compare folders

IntelliJ IDEA lets you compare files in two folders against their file size, content, or timestamp. The differences are displayed in the [Diff Viewer for
Folders](differences-viewer-for-folders.html).

![Comparing folders](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij_compareFolders.png)

The top pane lists all files in the selected folders, while the bottom pane shows the differences between two versions of the selected file (refer to [Compare files](#comparing_files)).

Procedure: Compare folders

1. Select the folders you want to compare in the   Project tool window  (`Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+1` (NetBeans), `Ctrl+Alt+L` (Visual Studio), `⌘ ⌥ L` (Visual Studio (macOS)), `Alt+1` (Eclipse), `Alt+1` (Eclipse (macOS))) .

> **Note:**
> You can also open the Diff Viewer without running IntelliJ IDEA. Run the following command: `<path to IntelliJ IDEA executable file> diff <path_1> <path_2>` where `path_1` and `path_2` are paths to the folders you want to compare.

2. From the context menu, choose Compare Directories  , or press `Ctrl+D` (Windows), `⌘ D` (macOS), `⌘ D` (IntelliJ IDEA Classic (macOS)), `⌘ D` (macOS System Shortcuts), `Ctrl+D` (XWin), `Ctrl+D` (GNOME), `Ctrl+D` (KDE), `Ctrl+D` (Emacs), `Ctrl+D` (Sublime Text), `⌘ D` (Sublime Text (macOS)), `Ctrl+D` (NetBeans), `Ctrl+D` (Visual Studio), `⌘ D` (Visual Studio (macOS)), `Ctrl+D` (Eclipse), `⌘ D` (Eclipse (macOS))  .

3. Use the following toolbar buttons to filter the list:

* ![right arrow](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.vcs.arrow_right.svg): click to display files that are present in the left folder, but are missing from the right one.

* ![left arrow](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.vcs.arrow_left.svg): click to display files that are present in the right folder, but are missing from the left one.

* ![not equal sign](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.vcs.not_equal.svg): click to display files that are present in both folders, but whose contents, timestamp or size are different.

* ![equal sign](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.vcs.equal.svg): click to display files that are present in both folders and that are identical with regard to the option selected in the Compare by dropdown.

4. Use the text filter in the search field to include or exclude files from the list:

* To include files, input a matching pattern. For example, `.txt` validates all paths that end with `.txt`.

* To exclude files, add `!` before your pattern. For example, `!build/*` excludes all files that are located within the build directory.

* Use `&` (`AND`) and `|` (`OR`) to combine several filters. For example, `*.txt|.xml&!build/*` validates all paths that end with `.txt` or `.xml` and are not located within the build directory.

Procedure: Synchronize folders

IntelliJ IDEA lets you sync the contents of two folders, or apply changes from one folder to another.

1. For each file, click the icon in the * column until you've set an action to be taken on that file.

* ![right arrow](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.vcs.arrow_right.svg): copy the selected item from the left to the right folder. If such file already exists in the right folder, it will be overwritten.

* ![left arrow](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.vcs.arrow_left.svg): copy the selected item from the right to the left folder. If such file already exists in the left folder, it will be overwritten.

* ![equal sign](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.vcs.equal.svg): no action will be performed (the two files are identical).

* ![not equal sigh](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.vcs.not_equal.svg): no action will be performed (the two files are different).

* ![close icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.closeSmall.svg): remove the selected item.

2. Do one of the following:

* To apply the selected action to the current item, click the Synchronize Selected button ![the Synchronize Selected button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.actions.resume.svg) on the toolbar or press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (NetBeans), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (Eclipse), `⏎` (Eclipse (macOS)).

* To apply the selected actions to all items, click the Synchronize All button ![the Synchronize All button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.actions.rerun.svg) on the toolbar.

Procedure: Compare different files in two folders

Sometimes a file may be present in one folder, and another file with a similar name in the other folder (for example, `VCS_library_1.4` and `VCS_library_1.5`). These may be versions of the same file that you want to compare. Also, there may be a situation when you think a file was renamed, but is otherwise identical to a file in another folder. IntelliJ IDEA lets you compare two files, one of which is present in the right folder, and another one in the left even though such files are treated as different entities.

> **Note:**
> This action is only available for files in folders with the same relative path.

1. Select the files you want to compare in the left and the right pane.

2. Click the Compare New Files with Each Other icon ![Compare new files with each other button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.vcs.merge.svg) on the toolbar. The differences between the selected files will be displayed in the bottom pane.

## Compare any text sources

Apart from comparing contents of files or folders, you can open an empty [Diff Viewer](differences-viewer.html) and paste any text or drag files into the right and left panels to compare. This can be useful, for example, if you want to compare the console output of an application with the output from a slightly modified version of the same application.

Procedure:

1. Press `Ctrl+Shift+A` (Windows), `⌘ ⇧ A` (macOS), `⌘ ⇧ A` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ P` (macOS System Shortcuts), `Ctrl+Shift+A` (XWin), `Ctrl+Shift+A` (GNOME), `Ctrl+Shift+A` (KDE), `Escape, X` (Emacs), `Ctrl+Shift+P` (Sublime Text), `⌘ ⇧ P` (Sublime Text (macOS)), `Ctrl+I` (NetBeans), `Ctrl+Shift+A` (Visual Studio), `⌘ ⇧ A` (Visual Studio (macOS)), `Ctrl+Shift+A` (Eclipse), `⌘ 3` (Eclipse (macOS)) and start typing to locate the Open Blank Diff Window action.

2. Paste any text you want to compare in the left and right panels.

Right-click either left or right panel and select Switch to Three-Side Viewer to compare any three text sources.

### Productivity tips

Assign a shortcut for the 'Open Blank Diff' action
: On  the Keymap settings page `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) , locate this action under Version Control Systems | Diff & Merge.

Swap sides
: You can swap sides in the Diff Viewer by pressing the ![swap sides](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.actions.swapPanels.svg) icon on the toolbar.

Open Diff in a separate window
: By default, Diff Viewer opens in an editor tab. You can configure the settings to open the viewer in a separate window instead. On  the Advanced Settings settings page `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) , disable the Open Diff as Editor Tab option.

## Compare via an external diff tool

You can set up and launch an external diff tool to compare your files and changes right from IntelliJ IDEA. Make sure to install the necessary diff tool on your machine beforehand.

Procedure: Configure an external diff tool

1. Press `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) to open settings and then select `Tools | Diff & Merge | External Diff Tools`.

2. Select the Enable external tools option.

![Enable external diff tools](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij_enable_external_diff_tools.png)

3. In the Configure external tools section, click ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg).

4. In the Add An External Tool dialog that opens, fill in the following details:

* Tool group: select Diff tool from the list.

* Program path: specify the path to the diff tool executable in your system.

* Argument pattern: if necessary, adjust the pattern for displaying changes, where: * %1 - local changes * %2 - content from the remote server * %3 - the current version without local changes

![Add kdiff3 as an external diff tool](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij_add_external_tool.png)

Click Test Diff or Test Three-Side Diff to check that the external diff tool launches from IntelliJ IDEA successfully.

5. Click OK to save the changes.

Procedure: Launch an external diff tool from IntelliJ IDEA

* When examining differences in Diff Viewer, click ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.general.externalTools.svg) to have IntelliJ IDEA launch the configured external diff tool.

![Launch kdiff3](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij_clipboard_editor_diff_viewer.png)

## See also

### Procedures

[Compare file and folder versions using Diff viewer](comparing-file-versions.html) [Compare deployed files and folders with their local versions](comparing-deployed-files-and-folders-with-their-local-versions.html) [Compare files from the command line](command-line-differences-viewer.html)

### Reference

[Diff Viewer for files](differences-viewer.html) [Diff Viewer for folders](differences-viewer-for-folders.html)

