FC - Compare Files
It is common to want to see what changed after editing a configuration file, or to check whether a backup is identical to the current file.
The FC command compares two files and shows where they differ. You do not need to install a dedicated diff tool; Command Prompt is enough for a quick check.
Basic Usage
Give FC the two files you want to compare.
FC [options] file1 file2
When the Files Are Identical
If the contents are the same, the following is displayed.
When the Files Differ
If the contents differ, each differing section is shown for each file, separated by *****.

中小企業経営者のためのRPA入門 RPA導入を成功させる方法

60分でわかる! AIエージェント 超 入門

コマンドラインの黒い画面が怖いんです。

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門
In this example, mode=debug in old.txt has become mode=release in new.txt. A few matching lines before and after the difference are shown as well.
The wording of the messages depends on the Windows display language. The examples here use English output.
In PowerShell, fc is an alias for Format-Custom, so the commands in this article will not work as written. Type fc.exe when using it from PowerShell.
FC Options
Commonly used options are as follows.
| Option | Description |
|---|---|
/B | Compare as binary, byte by byte |
/C | Ignore case |
/N | Show line numbers (text comparison) |
/W | Treat runs of spaces and tabs as one space, and ignore leading and trailing whitespace |
/T | Do not expand tabs to spaces |
/L | Compare as ASCII text |
/U | Compare as Unicode (UTF-16) text |
/A | Show only the first and last line of each differing section |
/LBn | Set the maximum number of consecutive mismatches (default is 100 lines) |
/nnnn | Set how many consecutive lines must match after a mismatch to resync (default is 2) |
/C - Ignore Case
Case is significant by default. Add /C to ignore it.
/N - Show Line Numbers
Add /N to see which lines differ.
In a long file, line numbers let you jump straight to the spot in your editor. Leave it off if you do not need it.
/W - Ignore Whitespace Differences
Files that differ only in indentation or in the number of spaces within a line are reported as different by default. With /W, runs of spaces and tabs are treated as a single space, and leading and trailing whitespace is ignored, so these differences are skipped. However, the presence or absence of whitespace itself is still treated as a difference.
/B - Compare Binary Files
For non-text files such as images or executables, add /B to compare byte by byte.
Each line shows “position from the start (hexadecimal): byte in file 1, byte in file 2”. In the example, the bytes at offsets 0x42 and 0x43 differ (offsets start at 0). If the files have different lengths, a message saying so is displayed and the exit code also reports a difference.
Files with the extensions .exe, .com, .sys, .obj, .lib, and .bin are compared as binary even without /B. All other files are compared with /L (ASCII text comparison).
/U - Compare Unicode (UTF-16) Text
For text files saved as UTF-16, the default ASCII comparison displays the differences as garbled text. Add /U in that case.
Comparing files with different encodings (for example UTF-8 and Shift_JIS) reports differences even when the text reads the same. Unify the encoding before comparing. See the related articles for more on encodings.
Compare Multiple Files with Wildcards
You can use wildcards such as * and ? in file names. For example, you can compare same-named text files in two folders at once.
FC only compares files directly inside the specified folders. To compare whole folders including subfolders, you can combine PowerShell’s Compare-Object with Get-ChildItem and Get-FileHash. Note that robocopy /L (list only, without copying) reports new, updated, and missing files based on size and modified time; it does not compare file contents.
Check for a Match with the Exit Code
FC reports the result as an exit code (ERRORLEVEL). You can use it in a batch file to decide whether two files are identical.
| Exit code | Meaning |
|---|---|
0 | The files are identical |
1 | The files differ |
2 | At least one of the files was not found |
-1 | Invalid syntax |
@echo off
fc /B "%~1" "%~2" >nul
if %errorlevel%==0 (
echo The files are identical.
) else if %errorlevel%==1 (
echo The files differ.
) else (
echo A file was not found, or the arguments are invalid.
)
Because only the verdict matters here, the comparison output is discarded with >nul.
if errorlevel 1 is true when the exit code is 1 or higher, so it also matches 2 (file not found), while -1 is false. This example compares the value directly, as in %errorlevel%==0.
Save the Result to a File
To keep the differences as a report, save them with redirection.
Practical Examples
See What You Changed in a Config File
Copy the file before editing, then compare.
After editing, check the differences.
Verify a Copy
After copying a large file, check that it matches the original. This can take a while for large files.
Summary
| Goal | Command |
|---|---|
| Compare two files | fc file1 file2 |
| Ignore case | fc /C file1 file2 |
| Show line numbers | fc /N file1 file2 |
| Ignore whitespace | fc /W file1 file2 |
| Compare as binary | fc /B file1 file2 |
| Check for a match | fc ... >nul and %errorlevel% |