6 guides

How to compare two files

Every practical way to find the difference between two files or two folders: the command line, your editor, Git, and a paste-and-compare tool for when they are not files yet.

Which method, when

You haveUseOne line
Two files on Linux or macOSdiffdiff -u a b
Two files on Windowsfc / PowerShellfc /N a b
Files open in an editorVS Code or Notepad++Select for Compare · Alt+D
Versions in a repositorygit diffgit diff main..feature -- file
Two foldersdiff -rq / robocopy /Ldiff -rq dirA dirB
Two texts from anywhereOnline diff checkerPaste, Compare
01

Step-by-step guides

Reading a diff

Whatever produced it, a diff answers one question: what would I change in the first file to get the second? Unified format, the one Git and most tools print, marks removed lines with a minus and added lines with a plus, with a few unchanged lines around them for context and an @@ header giving the line numbers. Changed lines appear as a removal followed by an addition. Once you can read that, every tool on this page is the same tool with a different front door.

FAQ

What is the quickest way to compare two files?

If they are on your machine: diff -u a b on Linux or macOS, fc a b on Windows, or select both in VS Code and choose Compare Selected. If they are two pieces of text in front of you, paste them into the online diff checker.

What do the symbols in a diff mean?

In unified diffs a minus marks a line removed from the first file and a plus a line added in the second; @@ headers give line numbers. Classic diff uses < and > for the same idea, and letters a, c and d for added, changed and deleted.

How do I compare two files without installing anything?

Use the online diff checker on this site: paste each file's contents and press Compare. The comparison runs in your browser; nothing is uploaded.

Can I compare two files on different computers?

Copy one file across, or paste both contents into the online checker and share the result as an expiring link with Log Share.

Two texts in front of you right now? Compare them online, in your browser.