Free Online Tool
Compare Two CSV Files Online
Compare an old and new CSV file to find added, removed, and modified records. Highlight cell-level differences, inspect schema shifts, and download difference reports directly in your browser.
File Comparison Inputs
Select or paste the Original (Before) and Updated (After) CSV files to compare.
What Changed Between the Files?
When reviewing updates between two exports, data drops, or database dumps, differences typically fall into four distinct categories:
In-Place Modifications
Rows that exist in both versions where one or more column values changed. The tool highlights exact previous and current values side by side.
New Records
Records present in the updated file that did not exist in the original file. These represent newly created database rows or inventory additions.
Deleted Records
Records present in the original file that were removed or filtered out in the updated export.
Column Additions & Removals
Structural alterations where new columns were introduced, unused fields dropped, or column order was shifted between exports.
Compare by Row Position or Key Column: Choosing the Right Mode
Selecting the appropriate comparison mode determines how the comparator pairs rows:
1. Key Column (Recommended)
Matches rows using an exact unique identifier (such as id, sku, or email). Even if rows were sorted differently, reordered, or had rows inserted at arbitrary positions, key-column matching reliably pairs the same logical record and reports true data mutations.
2. Row Position
Compares rows strictly line-by-line (row 1 to row 1, row 2 to row 2). This mode is ideal for fixed sequence files such as time-series logs or files without unique primary keys. Note that inserting a single row near the top causes all subsequent rows to shift and appear modified.
How to Compare Two CSV Files Step-by-Step
- Load your files: Drag and drop your original CSV into the left panel and the updated version into the right panel, or paste raw text directly.
- Choose matching mode: If your tables contain a unique identifier, select "Key Column" and choose the ID header. Otherwise, use "Row Position".
- Execute comparison: Click "Compare CSV Files". The engine validates RFC 4180 quoting, aligns records, and computes additions, deletions, and cell edits.
- Filter & download: Use the filter tabs to isolate changed or added rows, and download focused CSV or JSON difference reports.
How to Compare Two CSV Files in Python with Pandas
If you need to automate CSV diffing in a data pipeline or CI/CD test suite, you can compare DataFrames programmatically using pandas outer merges and indicators:
import pandas as pd
def compare_csv_files(before_path: str, after_path: str, key_col: str = "id") -> dict:
"""
Compare two CSV files using pandas outer merge to find
added, removed, and modified records based on a unique key.
"""
df_old = pd.read_csv(before_path)
df_new = pd.read_csv(after_path)
# 1. Outer merge with indicator column to detect additions and removals
merged = pd.merge(
df_old,
df_new,
on=key_col,
how="outer",
suffixes=("_old", "_new"),
indicator=True,
)
added = merged[merged["_merge"] == "right_only"]
removed = merged[merged["_merge"] == "left_only"]
common = merged[merged["_merge"] == "both"]
# 2. Check for cell-level value differences among common rows
non_key_cols = [c for c in df_old.columns if c != key_col and c in df_new.columns]
changed_records = []
for _, row in common.iterrows():
diffs = {}
for col in non_key_cols:
val_old = row[f"{col}_old"]
val_new = row[f"{col}_new"]
if pd.notna(val_old) and pd.notna(val_new) and val_old != val_new:
diffs[col] = {"old": val_old, "new": val_new}
if diffs:
changed_records.append({"key": row[key_col], "changes": diffs})
return {
"added_count": len(added),
"removed_count": len(removed),
"changed_count": len(changed_records),
"unchanged_count": len(common) - len(changed_records),
"changed_details": changed_records,
}
# Example usage:
# report = compare_csv_files("employees_v1.csv", "employees_v2.csv", key_col="id")
# print(f"Added: {report['added_count']}, Removed: {report['removed_count']}, Changed: {report['changed_count']}")Need to inspect a single CSV file for syntax errors, ragged rows, or unclosed quotes before running a diff? Test it with ourfree online CSV validator.
Privacy Guarantee & Performance Limits
Your Files Stay in Your Browser
All parsing, record matching, and diff generation execute 100% locally in client-side JavaScript. No row data, key values, or cell contents are ever uploaded to any server or third-party analytics tool.
10 MB In-Memory Limit
To guarantee smooth browser responsiveness without memory exhaustion, the tool supports combined file sizes up to 10 MB. For multi-gigabyte datasets, use Python streaming or command-line diff tools.
Frequently Asked Questions
How do I compare two CSV files for differences?
Upload or paste your original CSV into the "Before" panel and your updated CSV into the "After" panel. Choose "Key Column" mode if your files share a unique record ID (such as id, sku, or email) so rows match even when reordered, or choose "Row Position" to compare records sequentially line-by-line. Click "Compare CSV Files" to view highlighted cell changes, summary counts, and download difference reports.
What is the difference between comparing by row position and comparing by key column?
Comparing by row position checks corresponding rows at the same sequential index (row 1 vs. row 1, row 2 vs. row 2). If a single row is inserted or removed near the top of the file, all subsequent rows shift and appear modified. In contrast, key-column comparison matches rows by an exact unique identifier regardless of physical order, preventing false differences when rows are sorted or rearranged.
What happens when rows are in a different order?
In Key Column mode, records are matched by their unique key value rather than their line number. If row 10 in the original file appears as row 2 in the updated file, the comparator pairs them correctly and marks the record as unchanged if their values match. In Row Position mode, reordered rows will be compared against whatever happens to be at that position, reporting differences.
Are my CSV files uploaded to a server?
No. All parsing, difference calculations, and report generation execute 100% locally in your web browser using client-side JavaScript. Your file data, cell contents, and comparison results are never transmitted to our servers or sent to any third-party service.
How do I compare two CSV files in Python with pandas?
In pandas, you can use DataFrame.compare() for position-aligned tables with identical shapes and indices: df1.compare(df2). For tables that may have added, removed, or reordered rows, use pandas.merge(df1, df2, on="id", how="outer", suffixes=("_old", "_new"), indicator=True) to identify rows present in only one file or modified across columns.