How to compare two files with the fc command in Windows

Last update: 14/08/2025
Author Isaac
  • The fc command compares files in text (ASCII/Unicode) or binary mode with options to ignore case, spaces, and tabs.
  • Key parameters: /a (abbreviated output), /b (binary), /w (compress spaces), /n (line numbers), /lb (buffer) and / (resynchronization).
  • It supports wildcards and returns exit codes (0 equal, 1 different, 2 error); alternatives include Windiff and Comp.

Compare files with the fc command in Windows

If you work with Windows daily and are concerned about detecting changes between versions of documents, scripts, or binaries, the `fc` command is an efficient tool that saves you time by accurately showing where two files differ. This built-in utility compares content and highlights discrepancies in both text (ASCII/Unicode) and byte (binary) modes.

Beyond basic use, fc offers powerful parameters to tailor the comparison to your needs: ignore case , compress spaces , number lines , manage tabs , work with wildcards , and adjust resynchronization . Mastering these options will allow you to evaluate real differences and avoid false positives due to formatting or spacing.

What is FC and where is it available?

The purpose of fc is straightforward: to compare two files or sets of files and display the differences . It's a Windows ecosystem tool that comes as a traditional executable, and on many computers, it's located in C:\WINDOWS\fc.exe . In PowerShell, there's an alias called fc that points to Format-Custom ; therefore, to avoid conflicts in PowerShell, it's best to explicitly run fc.exe when you want to compare files.

Various sources indicate that fc is available in Windows 12 , 11, 10, and server editions such as MS Server 2025, 2022, and 2019. Furthermore , there are implementations in other environments such as FreeDOS , with an expanded set of options and some unique behaviors that we will discuss below.

Using the fc command to compare files

Syntax of the fc command

The canonical syntax in Windows covers comparisons in both text and binary. You'll find two main forms, one for ASCII/Unicode mode and one for binary mode :

fc /a     ]     <archivo1> <archivo2>
fc /b <archivo1> <archivo2>

In practical terms, file1 and file2 are required, along with their paths if applicable. From there, you choose the options that best suit your comparison. To see the built-in help, use `fc /?` in the command prompt ( CMD ).

Most useful parameters and options (Windows)

The set of modifiers allows you to control the analysis in detail. These are the most relevant in the documented Windows FC :

  • /a: abbreviated output for text comparisons. Instead of listing all the distinct lines, shows only the first and last line of each difference block.
  • /b: binary mode, compares byte by byte without resynchronizing after the first mismatch. This is the default mode if the extensions are .exe, .com, .sys, .obj, .lib, or .bin.
  • /c: ignores case differences during text comparison.
  • /l: ASCII text mode, compares line by line and attempts to resynchronize after a mismatch. This is the default mode for text files.
  • /lb: sets the size of the internal line buffer in number of lines. By default they are 100 lines; if there are more than 100 different consecutive lines, FC cancels the comparison.
  • /n: displays line numbers during an ASCII comparison.
  • /off: includes files with the "offline" attribute, which are otherwise omitted.
  • /t: does not convert tabs to spacesThe default behavior is to treat tabs as spaces with a break every 8 columns.
  • /u: compares files as Unicode text.
  • /w: compresses white spaces (tabs and spaces) when comparing. With /w, fc treats long sequences of spaces as a single ignores spaces at the beginning and end of the line.
  • /: number of consecutive lines that must match after a difference to consider that the files have been synchronized again. The default value is 2.
  • Routes and names (archive): indicate the location of the files to be compared; both names are required.
  • /?: show help on the console.
  What are Group Policy Templates (.ADMX) used for? Their use, advantages, and examples in modern IT administration.

When you perform an ASCII comparison , fc formats the output with a specific pattern so you can see at a glance what changed. The typical order is: first filename, lines distinct from the first, first matching line, second filename, lines distinct from the second, and first matching line again.

In binary comparisons , mismatches are shown with a format of differing addresses and bytes. The notation you will see follows this scheme :

<XXXXXXXX: YY ZZ>

Here, XXXXXXXX is the relative hexadecimal address from the beginning of the file, and YY / ZZ are the different hexadecimal values ​​in file1 and file2 respectively. The addresses start at 00000000 and increment as fc iterates through the bytes.

Wildcards, buffers and special messages

fc accepts wildcards ( * and ? ) in filenames. If you use a wildcard in the first argument, it will compare all files that match the pattern against the file (or set) specified in the second argument. If the wildcard is in the second argument, fc reuses the corresponding name from the first.

For ASCII comparisons, fc uses an internal buffer capable of holding 100 lines by default. If the files exceed this range without being able to resynchronize with matches, fc stops and displays :

Resynch failed. Files are too different.

When you compare binary files larger than the available memory , fc doesn't fail: it processes both in parts, overlapping the next portion in memory and maintaining the same output as if they fit completely.

Practical examples of use

Comparing two text reports and viewing the abbreviated result is as simple as launching: in ASCII mode with difference block summary :

fc /a monthly.rpt sales.rpt

If you want to compare two batch files in binary and see the addresses where the bytes differ, try:

fc /b profits.bat earnings.bat

The output may include lines such as addresses and bytes in hexadecimal, and if one is longer, a warning like " FC: earnings.bat longer than profits.bat " will appear . If both files are identical, fc will indicate that there are no differences with a message similar to:

Comparing files profits.bat and earnings.bat
FC: no differences encountered

You can also cross-reference a file with all the .bat files in the current directory :

fc *.bat new.bat

Or compare a file with its namesake on another drive :

fc c:new.bat d:*.bat

And to match by name all the .bat files in the root of C: with those in D:

fc c:*.bat d:*.bat

Working from CMD step by step

If you prefer a guided tour, you can open Command Prompt as administrator , navigate to the working folder, and run the comparisons. Example :

  • Open CMD with elevated permissions from the search engine.
  • Navigate to folder containing the files, for example: cd C:\Users\tuusuario\Downloads.
  • Compare in normal mode (text): fc archivo1.txt archivo2.txt.
  • Compare in ASCII (line by line): fc /L archivo1.txt archivo2.txt.
  • See summary blocks when only the first line changes: fc /a archivo1.txt archivo2.txt.
  • Compare in Unicode where appropriate: fc /u archivo1.txt archivo2.txt.
  • Apply wildcards To compare many TXT files with one file: fc *.txt archivo1.txt.

Keep in mind that If you run these commands in PowerShell, to avoid the alias to Format-Custom, use fc.exe explicitly (for example, fc.exe /a ...). This way you make sure to invoke the file comparator.

  How one can Add Watermark in Phrase Paperwork

Key Differences: ASCII/Unicode vs. Binary

In ASCII or Unicode mode , fc understands the concept of lines and allows you to number them (/n), ignore uppercase/lowercase letters (/c), compress spaces (/w), or respect tabs (/t). This is ideal for code, reports, configurations, and any text file.

Binary mode (/b) treats the file as a sequence of bytes. It doesn't resynchronize after the first mismatch and is the ideal way to verify that two executables, libraries, or other binaries are exactly the same. If you need to validate byte-by-byte integrity, this is the mode for you.

In addition to choosing the mode, you can adjust the resynchronization in text comparisons with /<nnnn> to require more (or fewer) identical lines after a misalignment before realigning. The default value is 2.

For comparisons with a lot of space noise, use /w and you'll forget about differences due to tabs or extra spaces, while /t helps when you want tabs to count as actual tabs. These two options make a difference in tabbed files or files with varying indentation.

Dumping results and large files

When the output is large, reading it in the console can be impractical. Redirect the output to a file for more detailed analysis or to look for patterns.

fc archivo1.txt archivo2.txt > diff.txt

This saves the entire report as a diff.txt file , allowing you to open it with your favorite editor, share it, or version it. This trick is especially useful for very long logs or listings.

Exit codes

If you call `fc` from scripts or automated tasks, you'll be interested in its exit code . On Windows , the most common signals are:

Exit code Meaning
0 The files are identical.
1 The files are different.
2 An error occurred during the comparison.

In the FreeDOS variant, additional ERRORLEVELs related to invalid parameters or failures to open/locate files are documented . Remember that the semantics may vary between platforms.

Integrated alternatives and related utilities

In addition to fc, Windows offers complementary utilities that can be incredibly useful depending on the situation. Windiff.exe provides a graphical interface for visually comparing text differences and folders. In Windows 2000 and later, it was included in the Support\Tools folder of the original CD (installable with Setup.exe ), and also within the Support.cab file of each Service Pack. In Windows NT 4.0, it was distributed with the Resource Kit.

  Downside Occurred With This Webpage So It was Reloaded

With Windiff, you can compare two files or entire directory trees , switching between outline mode (state summary) and expanded mode (line-by-line differences). Results are color-coded , and you can select the left file, the right file, or both from the menu. It also supports launching from the command line and includes a help file (Windiff.hlp).

Another classic console tool is Comp.exe , useful for comparing ASCII and binary files, even between computers . A typical example for comparing DLLs between machines would be:

comp C:\Winnt\System32\*.dll \\DifferentComputerName\C$\Winnt\System32\*.dll

If you need to verify that a local file and remote file are identical and you can't compare them directly, a historical resource is to use a external compressor like Pkzip.exe on both sides with zero compression (pkzip -e0) and check the CRC32 with pkzip -v. If the CRCs match, the files are equal.Third-party products like this one are the responsibility of their manufacturers.

Particularities of fc in FreeDOS

The FreeDOS version of fc expands the range of options and offers several nuances. In addition to the classic switches (/A, /B, /C, /L, /N, /T, /U, /W) , it incorporates others such as:

  • /LBn: Sets the maximum number of different consecutive ASCII lines in n.
  • /Mn: difference limit in binary en n bytes (default 20, with /M0 for unlimited). Use /M without number is equivalent to /M0.
  • /Q: does not show the detailed list of differences.
  • /R: shows a brief final report (always active with /S).
  • /S: descends into subdirectories to broaden the scope of the comparison.
  • /X: hides context lines in text comparison.
  • /nnn: sets the minimum number of consecutive matching lines to resynchronize.

In FreeDOS, fc is aware of long filenames when the system supports them, and in binary mode, it displays offsets, hex values, and printable ASCII characters when applicable. By default, it stops binary comparison after 20 differences , unless you use /M0 . There is a known limitation: in text mode, only the first 32765 lines are compared , and the rest are ignored. Exit codes include full match, detected differences, invalid parameters, file not found, or opening errors.

compare two files in notepad++
Related articles:
How to Compare Two Files in Notepad++