FC - Compare Files

Maintained on

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.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>fc old.txt new.txt
Comparing files old.txt and new.txt
FC: no differences encountered
C:\users\user>

When the Files Differ

If the contents differ, each differing section is shown for each file, separated by *****.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>fc old.txt new.txt
Comparing files old.txt and new.txt
***** old.txt
port=8080
mode=debug
log=on
***** new.txt
port=8080
mode=release
log=on
*****
C:\users\user>
おすすめ書籍※ 広告を含む場合があります
中小企業経営者のためのRPA入門 RPA導入を成功させる方法

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

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

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

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

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

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかる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.

Output depends on your environment

The wording of the messages depends on the Windows display language. The examples here use English output.

In PowerShell, type fc.exe

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.

OptionDescription
/BCompare as binary, byte by byte
/CIgnore case
/NShow line numbers (text comparison)
/WTreat runs of spaces and tabs as one space, and ignore leading and trailing whitespace
/TDo not expand tabs to spaces
/LCompare as ASCII text
/UCompare as Unicode (UTF-16) text
/AShow only the first and last line of each differing section
/LBnSet the maximum number of consecutive mismatches (default is 100 lines)
/nnnnSet 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.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>fc /C old.txt new.txt

/N - Show Line Numbers

Add /N to see which lines differ.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>fc /N old.txt new.txt
Comparing files old.txt and new.txt
***** old.txt
1: port=8080
2: mode=debug
3: log=on
***** new.txt
1: port=8080
2: mode=release
3: log=on
*****
C:\users\user>
/N helps with long files

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.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>fc /W old.txt new.txt

/B - Compare Binary Files

For non-text files such as images or executables, add /B to compare byte by byte.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>fc /B backup.zip current.zip
Comparing files backup.zip and current.zip
00000042: 1F 2A
00000043: 8B 00
C:\users\user>

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.

Comparison mode is chosen by extension

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.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>fc /U utf16-a.txt utf16-b.txt
Mind the character encoding

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.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>fc C:\backup\*.txt C:\work\*.txt
FC does not compare folders recursively

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 codeMeaning
0The files are identical
1The files differ
2At least one of the files was not found
-1Invalid 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 also true for 2 and above

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.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>fc /N old.txt new.txt > diff.txt

Practical Examples

See What You Changed in a Config File

Copy the file before editing, then compare.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>copy config.ini config.ini.bak

After editing, check the differences.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>fc /N config.ini.bak config.ini

Verify a Copy

After copying a large file, check that it matches the original. This can take a while for large files.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>fc /B D:\data\archive.zip E:\backup\archive.zip

Summary

GoalCommand
Compare two filesfc file1 file2
Ignore casefc /C file1 file2
Show line numbersfc /N file1 file2
Ignore whitespacefc /W file1 file2
Compare as binaryfc /B file1 file2
Check for a matchfc ... >nul and %errorlevel%

Quiz

Practice Problem

Which command compares two text files and shows the line numbers of the differing lines?

回答がサーバーに送信されることはありません
Practice Problem

What exit code does FC return when the two files are exactly identical?

回答がサーバーに送信されることはありません
#Command Prompt #Batch File #FC #Command #File Comparison