sturdybits

Guides / Compare Sheets

How to compare two CSV files for differences

29 November 2026

The quickest way to compare two CSV files is a text comparison: fc or PowerShell on Windows, or diff on a Mac. That shows which lines changed. If you want to see which cells changed, or the rows are in a different order, open both files in a spreadsheet tool, but import them carefully. Excel quietly changes some values when it opens a CSV, and the comparison then reports differences that aren't really there.

What can go wrong when you open a CSV in Excel

A CSV is plain text, and when you double-click one Excel guesses what each value means. Common surprises:

If you compare two files after Excel has changed them, you're comparing Excel's guesses, not the data.

1. Compare the files as text

Good for: a quick check of whether anything changed, and which lines.

Windows (Command Prompt):

fc /n old.csv new.csv

fc lists the blocks of lines that differ, with line numbers.

Windows (PowerShell), when rows may be in a different order:

Compare-Object (Get-Content old.csv) (Get-Content new.csv)

This ignores order and lists lines that appear in only one file: <= means only in the first, => only in the second.

Mac or Linux (Terminal):

diff -u old.csv new.csv

Lines starting with - are only in the old file, and lines starting with + only in the new one.

Text comparison is exact, because nothing gets reformatted. The limits: a single changed value shows as a whole changed line, so in a wide file you still have to find the cell, and if one file uses Windows line endings and the other doesn't, every line can look different.

2. Import into Excel without the guessing

Good for: comparing cell by cell with formulas.

Instead of double-clicking the file:

  1. In a blank workbook, choose Data > From Text/CSV and pick the file.
  2. In the preview, check the Delimiter is right, and set Data Type Detection to Do not detect data types. Everything comes in as text, so leading zeros and long numbers survive.
  3. Choose Load, then repeat for the second file.

You can then flag changed cells with a formula like =IF(Old!A1<>New!A1, "Old: "&Old!A1&" | New: "&New!A1, ""), or match rows by an ID column with XLOOKUP if the order differs. Our guide to comparing two Excel files covers both.

Because everything is text, 120.5 and 120.50 will show as different even though they're the same number, so keep an eye on number formatting.

3. Use a tool that reads the CSV directly

Good for: big exports, re-sorted rows, and comparing an export with a spreadsheet.

Compare Sheets reads .csv and .tsv files directly, works out whether the delimiter is a comma, semicolon or tab, and keeps IDs with leading zeros as they are. Numbers are compared as numbers, so 120.50 and 120.5 count as the same. It lines up inserted, deleted and moved rows, or matches rows by an ID column you choose, and it can compare a CSV against an .xlsx workbook. It runs in your browser and the files never leave your computer. The free version compares the first 1,000 rows, and you can try it with sample files.

Quick answers

Why does every line show as different? Usually line endings (Windows and Mac/Linux end lines differently) or a different column order. Text tools compare lines exactly, so either makes every line "change".

How do I compare two CSV files with rows in a different order? Use PowerShell's Compare-Object, which ignores order, or match rows by a unique ID column in Excel or a comparison tool.

Can I compare a CSV export with an Excel file? Yes. Import the CSV into Excel as text, as above, or use a tool that reads both formats.