Developer11 min readUpdated 2026-09-25

How to Merge CSV Files Into One (5 Free Ways)

Tools mentioned in this guide

Merging CSV files means stacking the rows from several files into one, under a single header row. It is the job you have when a system exports one file per month, per store or per campaign, and you need them all in one place to sort, filter or import.

The quickest way is the free FileNaut CSV Merge tool: drop the files in, click Merge, download one CSV. It runs in your browser, so nothing is uploaded.

The hard part is not the stacking. It is what happens when the files are not quite identical. A header spelled Email in one file and email in another. A column that only some files have. A ZIP code like 01234 that turns into 1234. A file with no line break at the end, which glues its last row onto the next file's first row. None of these produce an error message. You find out later, when numbers do not add up.

We built twelve small test files, each designed to trigger one of those problems, and ran them through every method below. This guide covers five ways to merge CSV files, which one to use, and what each gets wrong.

Before you merge: a 60-second check

Open two of the files in a plain text editor (Notepad, TextEdit, VS Code), not in Excel, which changes values as it opens them. Look at the first line of each.

  • Are the column names identical? Same spelling, same capitals, no trailing spaces. Email and email are two different columns to every tool on this page.
  • Same columns in every file? Different order is fine for the better methods. Missing or extra columns need a method that keeps them (Methods 1 and 5).
  • Same separator? Most files use commas. Files exported in much of Europe use semicolons.
  • Accented letters look right? If you see é or � where é should be, the file is in an older encoding. Re-save it as CSV UTF-8 before merging.

If you are not sure what a CSV actually contains under the hood, our guide to CSV files explains the format in five minutes.

Method 1: Merge CSV files in your browser (fastest)

Best for: most people, most of the time. No install, no formulas, and the files never leave your computer.

  1. Open CSV Merge.
  2. Drag your CSV files onto the page, or click Browse Files and select several at once. You can add more in a second batch; they join the bottom of the list.
  3. Leave Files have headers (first row) ticked if each file starts with a row of column names, which almost all do.
  4. Click Merge CSVs. A preview of the first ten rows appears.
  5. Click Download Merged CSV to save merged.csv.

Rows are stacked in the order the files appear in the list. To move a file, remove it with the × and add it again, and it goes to the bottom.

What it handled correctly in our tests:

  • Columns in a different order are matched by name, so an email column lands under email even when it is the first column in one file and the third in another.
  • Columns only some files have are all kept. Rows from files without that column get a blank cell, and the tool lists those columns above the preview so you can check them.
  • Semicolon-separated files were detected automatically and merged with comma files. The output uses commas.
  • Leading zeros survived (01234 stayed 01234), because values are copied as text, never converted to numbers.
  • Commas and line breaks inside quoted cells ("Smith, Bob") came through intact, as did a file with no final line break and files with Windows line endings.
  • Size: two files of 250,000 rows each merged in under a second on a laptop.

What it does not do: it does not remove duplicate rows (a row in two files appears twice), and it reads every file as UTF-8, so a file saved in an older encoding shows Caf� No�l instead of Café Noël. Re-save such files as CSV UTF-8 first. Both fixes are covered below.

Method 2: Merge CSV files into one Excel workbook, one tab per file

Best for: keeping each file separate but in one place, for example twelve monthly reports you want to flick between rather than combine.

  1. Open Merge CSV to Excel and add your files.
  2. Click Merge to Excel Tabs.
  3. Download the .xlsx. Each CSV becomes its own sheet, named after the file.

Sheet names are trimmed to Excel's 31-character limit, and characters Excel forbids in sheet names, such as [ ] in sales [2024].csv, are replaced with underscores. Every cell arrives as text, which is why leading zeros survive. If you need to sum a column of numbers, select it and use Data → Text to Columns → Finish to convert it.

If you want everything on one sheet in Excel, merge with Method 1 first, then open the result with CSV to Excel.

Method 3: Combine CSV files in Excel with Power Query

Best for: a folder that gets a new file every week or month. You set it up once, then click Refresh.

  1. Put all the CSV files in one folder, with nothing else in it.
  2. In Excel, go to Data → Get Data → From File → From Folder and pick the folder.
  3. Click Combine → Combine & Transform Data. Excel uses the first file as the template and shows a preview.
  4. In the Power Query editor, check each column's type. Set ID, ZIP and phone columns to Text so their leading zeros are kept.
  5. Click Close & Load. The combined table lands on a new sheet.

Next month, drop the new file into the folder and click Data → Refresh All.

Two cautions. Power Query matches columns by name, so a header spelled differently in one file becomes a separate, mostly empty column. And it adds a Source.Name column recording which file each row came from, which is useful, so keep it unless you have a reason not to. These steps are for Excel for Microsoft 365 on Windows. Menus differ on Mac and in older versions, and we did not test every edition.

Method 4: Merge CSV files from the command line

Best for: many files, or merging as part of a script. On a Mac or Linux, open Terminal in the folder with your files and run:

awk 'FNR==1 && NR!=1 {next} {print}' *.csv > merged.txt
mv merged.txt merged.csv

This prints the first file in full, then every other file minus its first line (the header). It writes to .txt first so the output is not caught by *.csv if you run it again.

You will often see this version recommended instead:

head -n 1 first.csv > merged.csv
tail -n +2 -q *.csv >> merged.csv

Avoid it. It copies the bytes exactly, so if any file lacks a line break after its last row, that row gets glued onto the next file's first row. In our test, ...,02139 and 12,Ivy,... came out as one row: ...,0213912,Ivy,.... No error, one corrupted record. The awk version adds the line break itself and got it right.

Both command-line methods assume every file has the same columns in the same order. They stack lines, not columns, so a reordered file silently puts emails under the wrong heading. For files that differ, use Method 1 or Method 5.

On Windows, copy *.csv merged.csv in Command Prompt joins the files but keeps every file's header row, which you then have to delete by hand. We did not test the Windows commands for this guide.

Method 5: Merge CSV files with Python

Best for: repeatable jobs, very large files, or when you also want to clean the data. This version uses only Python's standard library, so there is nothing to install. It keeps every column from every file, matches columns by name, and leaves blanks where a file lacks a column:

import csv, glob

files = sorted(f for f in glob.glob("*.csv") if f != "merged.csv")
rows, columns = [], []
for name in files:
    with open(name, newline="", encoding="utf-8-sig") as f:
        reader = csv.DictReader(f)
        for col in reader.fieldnames:
            if col not in columns:
                columns.append(col)
        rows.extend(reader)

with open("merged.csv", "w", newline="", encoding="utf-8") as f:
    writer = csv.DictWriter(f, fieldnames=columns)
    writer.writeheader()
    writer.writerows(rows)
print(f"{len(files)} files, {len(rows)} rows, {len(columns)} columns")

If you already use pandas:

import glob
import pandas as pd

files = sorted(f for f in glob.glob("*.csv") if f != "merged.csv")
frames = [pd.read_csv(f, dtype=str, keep_default_na=False, encoding="utf-8-sig") for f in files]
merged = pd.concat(frames, ignore_index=True)
merged.to_csv("merged.csv", index=False)

Three details in those scripts matter, and each was checked:

  • if f != "merged.csv" keeps the output out of the input. Without it, running the script a second time reads last run's merged.csv as another input. In our test that silently doubled the result from 8 rows to 16.
  • dtype=str stops pandas converting columns to numbers. Without it, our ZIP code 01234 came out as 1234.
  • encoding="utf-8-sig" strips the invisible byte-order mark that Excel puts at the start of "CSV UTF-8" files. Otherwise the first column's name can read as \ufeffid and fail to match id in the other files.

Which method should you use?

Your situationUse
A handful of files, onceCSV Merge in your browser
Columns differ between filesCSV Merge or the Python script (both keep every column)
Keep each file on its own tabMerge CSV to Excel
A new file lands in a folder every monthExcel Power Query (set up once, then Refresh)
Hundreds of identical files, or a scriptThe awk command, or Python
Files contain private dataAnything on this page except an upload-based website. CSV Merge runs locally in your browser

What goes wrong when you merge CSV files (and how to fix it)

Every one of these happened in our tests, and none produced an error.

1. Headers that almost match

Email, email and Email (with a trailing space) are three different columns. A method that keeps every column gives you three half-empty columns. A method that stacks lines puts the data under whatever the first file called it. Fix: open each file in a text editor and make the header rows identical before merging.

2. Leading zeros disappear

ZIP codes, phone numbers, product codes and IDs such as 00742 lose their zeros the moment something treats them as numbers. That happens when you open the file in Excel by double-clicking it, and when pandas reads it with default settings. Fix: merge with a method that keeps values as text (all five on this page do, configured as shown), and open the result with CSV to Excel, which keeps them. Our CSV to Excel guide covers this in detail.

3. Garbled accents

Older versions of Excel save "CSV" in a Windows encoding rather than UTF-8. Merge one of those with UTF-8 files and Café becomes Caf�. Once that replacement character is written, the original letter is gone. Fix: open the odd file in Excel or a text editor and save it as CSV UTF-8, then merge. If the merged file looks fine in a text editor but garbled in Excel, the file is fine: import it through Data → From Text/CSV and pick UTF-8.

4. Rows glued together

A file whose last row has no line break after it will merge its final row into the next file's header or first row, with any method that copies bytes directly. That includes the popular head/tail command and pasting files together in a text editor. Fix: use a method that parses the CSV (Methods 1, 2, 3 and 5, or the awk command).

5. Duplicate rows

Exports often overlap, for example a "last 30 days" file run twice a month. Merging keeps every row, so the overlap appears twice. Fix: after merging, remove duplicates in Excel with Data → Remove Duplicates, or add merged = merged.drop_duplicates() to the pandas script. Decide first what "duplicate" means for your data. Two identical orders on the same day may both be real.

Frequently asked questions

How do I combine multiple CSV files into one without Excel? ▼
Use a browser tool such as FileNaut CSV Merge: add the files, click Merge CSVs, and download one file. It works on any computer with a modern browser, including Chromebooks, and the files are processed locally rather than uploaded. On a Mac or Linux you can also use the one-line awk command in Method 4.
Can I merge CSV files that have different columns? ▼
Yes, with a method that matches columns by name. CSV Merge and the Python script both build the output from every column found in any file and leave cells blank where a file lacks that column. Command-line stacking (awk, head/tail, copy) does not do this. It assumes every file has the same columns in the same order.
How do I merge two CSV files by a common column, like an ID? ▼
That is a different job, called a join. Instead of stacking rows, it lines up two files side by side where an ID matches, such as customers in one file and their orders in another. None of the stacking methods here do that. Use XLOOKUP in Excel, a Merge Queries step in Power Query, or pd.merge(a, b, on="id") in pandas.
Is there a limit to how many CSV files I can merge? ▼
In a browser tool the limit is your computer's memory, not a file count. We merged two files of 250,000 rows each (about 19 MB of output) in under a second. For multi-gigabyte data, use the awk command or Python, which handle files far larger than a browser tab comfortably can. If you plan to open the result in Excel, remember that a worksheet holds at most 1,048,576 rows.
Why does my merged file have the header row repeated in the middle? ▼
The files were joined as plain text, so every file's header came along. It happens with copy *.csv on Windows, cat on Mac, and in CSV Merge if you untick "Files have headers". Leave that box ticked whenever your files start with column names, or use the awk command, which skips the first line of every file after the first.
Can I merge CSV files with different separators, like commas and semicolons? ▼
In CSV Merge, yes. It detected a semicolon-separated file automatically in our test and wrote the combined output with commas. Command-line stacking cannot do this, because it copies lines as they are. In Python, pass sep=";" (pandas) or delimiter=";" (csv module) for those files.
Is it safe to merge CSV files online? ▼
It depends on whether the site uploads your files. Many online converters send files to a server. FileNaut's CSV tools read the files inside your browser, and the merge happens on your own computer. For customer lists, payroll or anything regulated, a local method (a browser-based tool, Excel or a script) is the safer default.
How do I turn the merged CSV into an Excel file? ▼
Run it through CSV to Excel, or in Excel use Data → From Text/CSV rather than double-clicking the file, so you control how each column is read. To go the other way and split a workbook into CSVs, use Excel to CSV.

The short version

For a one-off merge, use CSV Merge: it matches columns by name, keeps every column, and preserves leading zeros. For a folder that grows every month, set up Power Query once. For scripts, use awk when the files are identical and Python when they are not.

Whichever you choose, compare the merged row count with the total of the input files. Then scan the header row for near-duplicate column names. Those two checks catch almost every silent merge failure.

Ready to try it?

Use the tool right now — free, no signup, no upload.